﻿######################
# REPUBLIC DECISIONS #
######################

# Adopt Republican Ideals/Adopt Republic Government
gdp_adopt_republic_government_decision = {
	title = gdp_adopt_republic_government_decision
	desc = gdp_adopt_republic_government_decision_desc
	selection_tooltip = gdp_adopt_republic_government_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/event_story/gdp_republican.dds"
	}

	sort_order = 40
	decision_group_type = realm

	cost = {
		prestige = {
			value = monumental_prestige_value
			if = {
				limit = { primary_title.tier >= tier_kingdom }
				multiply = 4
			}
			else_if = {
				limit = { primary_title.tier = tier_duchy }
				multiply = 2
			}
		}
		gold = {
			value = 200
			if = {
				limit = { primary_title.tier >= tier_kingdom }
				multiply = 8
			}
			else_if = {
				limit = { primary_title.tier = tier_duchy }
				multiply = 4
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 240
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	is_shown = {
		gdp_basic_can_adopt_republic_government_trigger = yes
	}

	is_valid = {
		save_temporary_scope_as = founding_ruler
		prestige_level >= 3
		capital_county = {
			popular_opinion >= 20
		}
		sub_realm_size < 25 # Large realm should just become admin instead
		capital_province = {
			province_size_level >= 3
		}
		OR = {
			is_independent_ruler = yes
			trigger_if = {
				limit = {
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
				custom_tooltip = {
					text = liege_has_granted_city_charter_duration
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = liege_has_granted_city_charter
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		show_as_tooltip = { # Actual effect is applied in follow-up event
			gdp_found_a_republic_effect = yes
		}
		trigger_event = republic_event.0001
	}

	ai_potential = {
		# AI rulers will only attempt to become republics if their capital is in an acceptable location
		capital_province ?= {
			geographical_region = world_europe
		}
		# And is of a culture we would expect to form republics
		culture ?= {
			OR = {
				# German cities
				has_cultural_pillar = heritage_central_germanic
				# Visby
				has_cultural_pillar = heritage_north_germanic
				# Italian city states
				has_cultural_tradition = tradition_republican_legacy
			}
		}
	}

	ai_will_do = {
		base = 100
	}
}

# Adopt Republican Ways - tribal equivalent of Adopt Feudal Ways
gdp_adopt_republican_ways_decision = {
	title = gdp_adopt_republican_ways_decision
	desc = gdp_adopt_republican_ways_decision_desc
	selection_tooltip = gdp_adopt_republican_ways_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/event_story/gdp_republican.dds"
	}

	sort_order = 100
	decision_group_type = major

	cost = {
		prestige = 500
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_tribal
		is_landed = yes
		highest_held_title_tier < tier_kingdom
	}

	is_valid = {
		save_temporary_scope_as = founding_ruler
		custom_description = {
			text = faith_is_reformed
			subject = root
			faith = { NOT = { has_doctrine_parameter = unreformed } }
		}
		prestige_level >= 2
		capital_county = {
			popular_opinion >= 20
		}
		highest_held_title_tier < tier_kingdom
		capital_province.province_size_level >= 3
		custom_description = { #You need to have 70% of all (non-regional/unique) tribal innovations!
			text = has_all_tribal_innovations
			subject = root.culture
			culture = {
				calc_true_if = {
					amount >= 10
					has_innovation = innovation_motte
					has_innovation = innovation_catapult
					has_innovation = innovation_barracks
					has_innovation = innovation_mustering_grounds
					has_innovation = innovation_bannus
					has_innovation = innovation_quilted_armor
					has_innovation = innovation_pattern_welding
					has_innovation = innovation_gavelkind
					has_innovation = innovation_crop_rotation
					has_innovation = innovation_city_planning
					has_innovation = innovation_casus_belli
					has_innovation = innovation_plenary_assemblies
					has_innovation = innovation_ledger
					has_innovation = innovation_prosperity_01
					has_innovation = innovation_currency_01
				}
			}
		}
		OR = {
			is_independent_ruler = yes
			trigger_if = {
				limit = {
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
				custom_tooltip = {
					text = liege_has_granted_city_charter_duration
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = liege_has_granted_city_charter
					has_variable = has_liege_permission_to_found_republic
					var:has_liege_permission_to_found_republic = liege
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = permafrost_feudal_ban
			NOT = { culture = { has_cultural_parameter = permafrost_cannot_become_feudal } }
		}
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		show_as_tooltip = { # Actual effect is applied in follow-up event
			custom_tooltip = {
				text = gdp_tribal_capital_becomes_city_tt
			}
			custom_tooltip = {
				text = gdp_other_tribal_holdings_become_castles_tt
			}
			if = {
				limit = {
					any_vassal_or_below = {
						government_has_flag = government_is_tribal
					}
				}
				custom_tooltip = {
					text = gdp_tribal_vassals_will_feudalize_tt
				}
			}
			if = {
				limit = {
					any_sub_realm_county = {
						OR = {
							has_county_modifier = mpo_siberian_permafrost_modifier
							has_county_modifier = mpo_siberian_permafrost_modifier_bad
						}
					}
				}
				custom_tooltip = {
					text = all_permafrost_will_clear
				}
			}
			gdp_found_a_republic_effect = yes
		}
		trigger_event = republic_event.0002
	}

	ai_potential = {
		is_independent_ruler = yes
		NOT = { mpo_has_gok_mongol_empire_trigger = yes }
		capital_province ?= {
			is_coastal = yes
			geographical_region = world_europe
		}
		culture ?= {
			OR = {
				has_cultural_pillar = heritage_central_germanic
				has_cultural_pillar = heritage_north_germanic
				has_cultural_pillar = heritage_east_slavic
				has_cultural_tradition = tradition_republican_legacy
			}
		}
	}

	ai_will_do = {
		base = 100
	}
}

# Adopt [ROOT.Char.Custom('GetTribalReformGovernment')|U] Ways
convert_to_feudalism_from_republic_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = realm
	sort_order = 40
	desc = convert_to_feudalism_from_republic_decision_desc

	is_shown = {
		government_has_flag = government_is_republic
		highest_liege_matching_rule:uses_assembly = this
	}

	is_valid = {
		is_independent_ruler = yes
		has_realm_law = republican_despot_succession_law
		prestige_level >= { # Depends on tier
			value = primary_title.tier
			subtract = 1
			min = 2
		}
	}

	cost = {
		prestige = 1000
		treasury = {
			value = 1000
			culture = {
				if = {
					limit = { has_cultural_era_or_later = culture_era_late_medieval }
					multiply = 1.75
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_high_medieval }
					multiply = 1.25
				}
				else_if = {
					limit = { has_cultural_era_or_later = culture_era_early_medieval }
					multiply = 1
				}
				else = {
					multiply = 0.75
				}
			}
		}
	}

	effect = {
		convert_to_feudalism_from_republic_effect = yes
		save_scope_as = actor
		trigger_event = ep3_decisions_event.4070
		hidden_effect = {
			every_vassal = {
				trigger_event = {
					id = ep3_decisions_event.4075
					days = 3
				}
			}
		}
	}

	ai_check_interval = 0

	ai_potential = {
		always = no
	}
}

# Restore the Roman Republic
gdp_restore_roman_republic_decision = {
	title = gdp_restore_roman_republic_decision
	desc = gdp_restore_roman_republic_decision_desc
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_roman_restoration.dds"
	}

	sort_order = 105
	decision_group_type = major

	cost = {
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_republic
		# Must have a culture that somehow descends from Rome
		culture = {
			OR = {
				has_cultural_tradition = tradition_republican_legacy
				has_cultural_pillar = heritage_latin
				any_parent_culture_or_above = { this = culture:roman }
				has_cultural_pillar = heritage_romanian
				has_cultural_pillar = heritage_italian
				has_cultural_pillar = heritage_cisalpine
				has_cultural_pillar = heritage_sardic
			}
		}
		# You may only restore it once
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_roman_republic
			}
		}
	}

	is_valid = {
		is_independent_ruler = yes
		has_realm_law = republic_tier_empire
		prestige_level >= max_prestige_level
		completely_controls = title:d_latium
		completely_controls = title:d_toscana
		completely_controls = title:d_ancona
		completely_controls = title:d_spoleto
		completely_controls = title:d_napoli
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_capable_adult = yes
		is_imprisoned = no
		NOR = {
			exists = title:h_roman_empire.holder
			exists = title:h_NEOW_rome.holder
		}
	}

	effect = {
		show_as_tooltip = { # Actual effect is applied in follow-up event
			gdp_restore_the_roman_republic_effect = yes
		}
		if = {
			limit = {
				capital_county != title:c_roma
			}
			custom_tooltip = restore_roman_republic_make_rome_capital_desc
		}
		trigger_event = republic_event.0100

		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_roman_republic
			}
			add_achievement_global_variable_effect = {
				VARIABLE = ep5_06_senatus_populusque_romanus_achievement_unlocked
				VALUE = yes
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 36
		hegemony = 0
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

# Accept Glorification - Once-per-lifetime decision at 100 popular opinion
gdp_glorification_decision = {
	title = gdp_glorification_decision
	desc = gdp_glorification_decision_desc
	selection_tooltip = gdp_glorification_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}

	sort_order = 82
	decision_group_type = republic

	cost = {
		prestige = 1000
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 240
		kingdom = 120
		empire = 60
		hegemony = 60
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_republic
		NOT = { has_character_flag = gdp_glorification_taken }
		capital_county = {
			popular_opinion = 100
		}
	}

	is_valid = {
		capital_county = {
			popular_opinion = 100
		}
		gdp_is_assembly_head_trigger = yes
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		send_interface_toast = {
			type = event_toast_effect_good
			title = gdp_glorification_decision_toast
			left_icon = root

			add_character_flag = gdp_glorification_taken
			capital_county ?= {
				add_popular_opinion = -25
			}
			add_character_modifier = gdp_glorification_modifier
			dynasty = { add_dynasty_prestige = 500 }
			save_scope_as = owner
			custom_tooltip = gdp_glorification_artifact_tt
			hidden_effect_new_object = {
				get_artifact_quality_effect = yes
				get_artifact_wealth_effect = yes
				scope:owner = {
					create_artifact = {
						name = gdp_glorification_artifact_name
						description = gdp_glorification_artifact_desc
						creator = scope:owner
						visuals = medallion
						type = curio
						rarity = illustrious
						decaying = no
						modifier = artifact_placeholder_modifier
						save_scope_as = newly_created_artifact
						wealth = scope:wealth
						quality = scope:quality
					}
				}
				scope:newly_created_artifact = {
					add_scaled_artifact_modifier_prestige_effect = yes
					add_scaled_artifact_modifier_dynasty_prestige_effect = yes
					remove_artifact_modifier = artifact_placeholder_modifier
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
	}

	ai_will_do = {
		base = 10
		modifier = {
			has_trait = ambitious
			add = 20
		}
		modifier = {
			has_trait = arrogant
			add = 10
		}
	}
}

# Solicit Patrician Patronage - Spend popular opinion to receive gold and gifts from patrician families
gdp_popular_gifts_decision = {
	title = gdp_popular_gifts_decision
	desc = gdp_popular_gifts_decision_desc
	selection_tooltip = gdp_popular_gifts_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/cooperative.dds"
	}

	sort_order = 60
	decision_group_type = republic

	cooldown = { years = 10 }

	cost = {
		prestige = 500
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 240
		kingdom = 120
		empire = 60
		hegemony = 60
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_republic
		gdp_is_assembly_head_trigger = yes
		capital_county = {
			popular_opinion >= 75
		}
	}

	is_valid = {
		capital_county = {
			popular_opinion >= 75
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		send_interface_toast = {
			type = event_toast_effect_good
			title = gdp_popular_gifts_decision_toast
			left_icon = root

			capital_county ?= {
				add_popular_opinion = -25
			}
			add_gold = {
				value = medium_gold_value
				min = 50
			}
			custom_tooltip = gdp_popular_gifts_artifact_tt
			hidden_effect = {
				capital_province = { save_scope_as = creature_location }
				random_list = {
					33 = {
						create_curio_artifact_effect = {
							OWNER = root
							CREATOR = root
						}
						scope:new_trinket ?= {
							reforge_transferred_artifact_effect = { RECEIVER = root }
						}
					}
					33 = {
						trigger = {
							domicile ?= { is_domicile_type = merchant_company }
						}
						create_creature_artifact_effect = {
							OWNER = root
							CREATOR = root
						}
					}
					33 = {
						create_library_artifact_effect = {
							OWNER = root
							CREATOR = root
							SUBJECT = flag:no
							TOPIC = flag:no
						}
						scope:newly_created_artifact ?= {
							reforge_transferred_artifact_effect = { RECEIVER = root }
						}
					}
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
	}

	ai_will_do = {
		base = 0
		modifier = {
			has_trait = greedy
			add = 20
		}
		modifier = {
			has_trait = ambitious
			add = 10
		}
		modifier = {
			gold < minor_gold_value
			add = 20
		}
	}
}

# Call for Popular Support - Spend popular opinion to gain extra vote strength in the next election
gdp_popular_mandate_decision = {
	title = gdp_popular_mandate_decision
	desc = gdp_popular_mandate_decision_desc
	selection_tooltip = gdp_popular_mandate_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/concerted.dds"
	}

	sort_order = 55
	decision_group_type = republic

	cooldown = { years = 10 }

	cost = {
		prestige = 500
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 240
		kingdom = 120
		empire = 60
		hegemony = 60
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_republic
		gdp_is_assembly_head_trigger = yes
		capital_county = {
			popular_opinion >= 50
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				NOT = { is_decision_on_cooldown = gdp_popular_mandate_decision }
			}
			custom_tooltip = {
				text = gdp_popular_mandate_no_active_mandate_desc
				NOT = { has_character_modifier = gdp_popular_mandate_modifier }
			}
		}
		capital_county = {
			popular_opinion >= 50
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		send_interface_toast = {
			type = event_toast_effect_good
			title = gdp_popular_mandate_decision_toast
			left_icon = root

			capital_county ?= {
				add_popular_opinion = -25
			}
			add_character_modifier = gdp_popular_mandate_modifier
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
	}

	ai_will_do = {
		base = 0
		modifier = {
			has_trait = ambitious
			add = 20
		}
		modifier = {
			has_trait = greedy
			add = 10
		}
		modifier = {
			capital_county = {
				popular_opinion > 75
			}
			add = 10
		}
	}
}

# Direct Civic Labor - Spend popular opinion to gain domicile construction bonuses
gdp_civic_labor_decision = {
	title = gdp_civic_labor_decision
	desc = gdp_civic_labor_decision_desc
	selection_tooltip = gdp_civic_labor_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fractious.dds"
	}

	sort_order = 50
	decision_group_type = republic

	cooldown = { years = 10 }

	cost = {
		prestige = 500
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 240
		kingdom = 120
		empire = 60
		hegemony = 60
	}

	is_shown = {
		has_gdp_dlc_trigger = yes
		government_has_flag = government_is_republic
		gdp_is_assembly_head_trigger = yes
		capital_county = {
			popular_opinion >= 25
		}
	}

	is_valid = {
		capital_county = {
			popular_opinion >= 25
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		send_interface_toast = {
			type = event_toast_effect_good
			title = gdp_civic_labor_decision_toast
			left_icon = root

			capital_county ?= {
				add_popular_opinion = -25
			}
			add_character_modifier = {
				modifier = gdp_civic_labor_modifier
				years = 10
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
	}

	ai_will_do = {
		base = 0
		modifier = {
			has_trait = diligent
			add = 15
		}
		modifier = {
			has_trait = ambitious
			add = 10
		}
		modifier = {
			capital_county = {
				popular_opinion > 50
			}
			add = 10
		}
	}
}

### Debase the Coinage ###
debase_the_coinage_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}
	desc = debase_the_coinage_decision_desc
	selection_tooltip = debase_the_coinage_decision_tooltip
	decision_group_type = major

	cooldown = { years = 10 }

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 24
		hegemony = 24
	}

	is_shown = {
		is_independent_ruler = yes
		is_landed = yes
		highest_held_title_tier >= tier_kingdom
		NOT = {
			government_has_flag = government_is_nomadic
		}
		OR = {
			AND = {
				NOT = {
					government_has_flag = government_has_treasury
				}
				debt_level >= 1
			}
			AND = {
				government_has_flag = government_has_treasury
				treasury_debt_level >= 1
			}
		}
		has_gdp_dlc_trigger = yes
	}

	is_valid = {

	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	cost = {
		prestige = massive_prestige_value
	}

	effect = {
		add_treasury_or_gold = {
			value = 0
			every_sub_realm_county = {
				add = {
					value = 0.37
					if = {
						limit = {
							prosperity_level > 0
						}
						multiply = prosperity_level
					}
					divide = {
						value = root.realm_size
						divide = 50
						min = 1
					}
				}
			}
			add = 215
			min = 250
			max = 1500
		}

		every_sub_realm_county = {
			custom = debase_the_coinage_decision_county_custom

			change_prosperity_level = -10
			add_county_modifier = {
				modifier = debase_coinage_county_modifier
				years = 20
			}
		}

		add_character_modifier = {
			modifier = debase_coinage_ruler_modifier
			years = 20
		}

		stress_impact = {
			just = major_stress_impact_gain
			content = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
	}

	ai_potential = {
		is_independent_ruler = yes
		highest_held_title_tier >= tier_kingdom
		OR = {
			AND = {
				NOT = {
					government_has_flag = government_has_treasury
				}
				debt_level >= 3
			}
			AND = {
				government_has_flag = government_has_treasury
				treasury_debt_level >= 3
			}
		}
		NOT = {
			any_vassal_or_below = {
				is_ai = no # don't economically devastate the vassal player
			}
		}
	}

	ai_will_do = {
		base = -20
		modifier = {
			add = {
				value = 5
				multiply = debt_level
			}
		}
		modifier = {
			treasury_debt_level > debt_level
			add = {
				value = 8
				multiply = treasury_debt_level
			}
		}
		modifier = {
			has_trait = greedy
			add = 8
		}
		modifier = {
			has_trait = deceitful
			add = 6
		}
		modifier = {
			has_trait = callous
			add = 5
		}
		modifier = {
			has_trait = arbitrary
			add = 4
		}
		modifier = {
			has_trait = ambitious
			add = 4
		}
		modifier = {
			has_trait = paranoid
			add = 3
		}
		modifier = {
			has_trait = wrathful
			add = 2
		}
		modifier = {
			has_trait = just
			add = -12
		}
		modifier = {
			has_trait = honest
			add = -10
		}
		modifier = {
			has_trait = shrewd
			add = -8
		}
		modifier = {
			has_trait = generous
			add = -6
		}
		modifier = {
			has_trait = compassionate
			add = -5
		}
		modifier = {
			has_trait = content
			add = -4
		}
		modifier = {
			has_trait = diligent
			add = -3
		}
		modifier = {
			stewardship >= 14
			add = -8
		}
		modifier = {
			stewardship >= 10
			stewardship < 14
			add = -4
		}
		modifier = {
			stewardship <= 4
			add = 4
		}
	}
}

gdp_banishment_approval_decree_decision = {
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { gdp_has_valid_indicted_character_trigger = yes }
				desc = gdp_banishment_approval_decree_decision_named
			}
			desc = gdp_banishment_approval_decree_decision
		}
	}
	desc = gdp_banishment_approval_decree_decision_desc
	selection_tooltip = gdp_banishment_approval_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes

	cooldown = { years = 5 }

	cost = {
		prestige = total_republic_decree_prestige_cost
	}

	is_shown = {
		government_has_flag = government_is_republic
		has_realm_law_flag = republic_banishment_approval_required
		has_gdp_dlc_trigger = yes
	}

	is_valid_showing_failures_only = {
		gdp_is_assembly_head_trigger = yes
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
		gdp_has_valid_indicted_character_trigger = yes
		trigger_if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			custom_tooltip = {
				text = gained_assembly_approval_banishment_desc
				NOT = { var:has_assembly_approval_banishment ?= var:gdp_indicted_character }
			}
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			var:gdp_indicted_character = { save_scope_as = indicted_character }
			custom_tooltip = {
				text = gdp_banishment_approval_decree_decision_effect_desc
				set_variable = {
					name = has_assembly_approval_banishment
					value = scope:indicted_character
				}
			}
		}
		else = {
			custom_tooltip = gdp_banishment_approval_decree_decision_effect_no_indicted_desc
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { always = yes }

	ai_approval = {
		value = 0
		if = {
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
			add = ai_decree_approval_indicted_pledged_kin_value
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}
			add = {
				value = -10
				desc = LAW_BASE_RELUCTANCE_DESC
			}
			add = ai_decree_approval_punitive_reluctance_value
			add = ai_decree_approval_indicted_character_value
			add = ai_decree_approval_indicted_grounds_value
		}
		add = ai_decree_approval_indicted_kin_value
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		prestige >= total_republic_decree_prestige_cost
		var:gdp_indicted_character ?= {
			imprisoner ?= root
			root = { has_banish_reason = prev }
			save_temporary_scope_as = indicted_character
		}
		NOT = { gdp_has_any_punitive_approval_for_trigger = { TARGET = scope:indicted_character } }
	}

	ai_will_do = {
		base = 0
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					has_relation_rival = root
					has_relation_nemesis = root
				}
			}
			add = 25
		}
		modifier = {
			var:gdp_indicted_character = { save_temporary_scope_as = indicted_character }
			house_has_feud_relation_with_trigger = { TARGET = scope:indicted_character }
			add = 20
		}
		modifier = {
			OR = {
				gg_first_and_second_are_opposite_sides_trigger = { FIRST = root SECOND = var:gdp_indicted_character }
				gg_target_house_head_is_opposite_side_trigger = {
					ACTOR = root
					TARGET = var:gdp_indicted_character
				}
			}
			add = 20
		}
		modifier = {
			var:gdp_indicted_character = { has_claim_on = root.primary_title }
			add = 15
		}
		modifier = {
			OR = {
				has_trait = ambitious
				has_trait = wrathful
				has_trait = vengeful
				has_trait = callous
				has_trait = arbitrary
			}
			add = 20
		}
		modifier = {
			has_trait = just
			add = 10
		}
		modifier = {
			OR = {
				has_trait = compassionate
				has_trait = forgiving
			}
			add = -25
		}
		modifier = {
			gdp_is_republican_despot_or_supporter_trigger = yes
			add = 20
		}
		modifier = {
			gdp_character_in_democratic_republic_trigger = yes
			add = 10
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_signorial }
			add = 15
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_agitation }
			add = 10
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_communal }
			add = -15
		}
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					is_close_family_of = root
					is_spouse_of = root
				}
			}
			factor = 0
		}
	}
}

gdp_proscription_approval_decree_decision = {
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { gdp_has_valid_indicted_family_trigger = yes }
				desc = gdp_proscription_approval_decree_decision_named
			}
			desc = gdp_proscription_approval_decree_decision
		}
	}
	desc = gdp_proscription_approval_decree_decision_desc
	selection_tooltip = gdp_proscription_approval_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes

	cooldown = { years = 10 }

	cost = {
		prestige = total_republic_proscription_decree_prestige_cost
	}

	is_shown = {
		government_has_flag = government_is_republic
		has_realm_law_flag = republic_banishment_approval_required
		has_gdp_dlc_trigger = yes
	}

	is_valid_showing_failures_only = {
		gdp_is_assembly_head_trigger = yes
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
		gdp_has_valid_indicted_family_trigger = yes
		trigger_if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			custom_tooltip = {
				text = gained_assembly_approval_proscription_desc
				NOT = { var:has_assembly_approval_proscription ?= var:gdp_indicted_character }
			}
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			var:gdp_indicted_character = { save_scope_as = indicted_character }
			custom_tooltip = {
				text = gdp_proscription_approval_decree_decision_effect_desc
				set_variable = {
					name = has_assembly_approval_proscription
					value = scope:indicted_character
				}
			}
		}
		else = {
			custom_tooltip = gdp_proscription_approval_decree_decision_effect_no_indicted_desc
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { always = yes }

	ai_approval = {
		value = 0
		if = {
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
			add = ai_decree_approval_indicted_pledged_kin_value
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}
			add = {
				value = -20
				desc = LAW_BASE_RELUCTANCE_DESC
			}
			add = ai_decree_approval_punitive_reluctance_value
			add = ai_decree_approval_indicted_character_value
			add = ai_decree_approval_proscription_grounds_value
		}
		add = ai_decree_approval_indicted_kin_value
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		prestige >= total_republic_proscription_decree_prestige_cost
		gdp_has_valid_indicted_family_trigger = yes
		var:gdp_indicted_character = { save_temporary_scope_as = indicted_character }
		gdp_has_proscription_grounds_trigger = { TARGET = scope:indicted_character }
		NOT = { gdp_has_any_punitive_approval_for_trigger = { TARGET = scope:indicted_character } }
	}

	ai_will_do = {
		base = 0
		modifier = {
			OR = {
				gg_first_and_second_are_opposite_sides_trigger = { FIRST = root SECOND = var:gdp_indicted_character }
				gg_target_house_head_is_opposite_side_trigger = {
					ACTOR = root
					TARGET = var:gdp_indicted_character
				}
			}
			add = 25
		}
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					has_relation_rival = root
					has_relation_nemesis = root
				}
			}
			add = 25
		}
		modifier = {
			var:gdp_indicted_character = { save_temporary_scope_as = indicted_character }
			house_has_feud_relation_with_trigger = { TARGET = scope:indicted_character }
			add = 25
		}
		modifier = {
			OR = {
				has_execute_reason = var:gdp_indicted_character
				has_banish_reason = var:gdp_indicted_character
			}
			add = 15
		}
		modifier = {
			OR = {
				has_trait = ambitious
				has_trait = wrathful
				has_trait = vengeful
				has_trait = callous
				has_trait = sadistic
			}
			add = 20
		}
		modifier = {
			OR = {
				has_trait = compassionate
				has_trait = forgiving
				has_trait = just
			}
			add = -30
		}
		modifier = {
			gdp_is_republican_despot_or_supporter_trigger = yes
			add = 20
		}
		modifier = {
			gdp_character_in_democratic_republic_trigger = yes
			add = -20
		}
		modifier = {
			house ?= {
				OR = {
					has_house_aspiration_parameter = republic_signorial
					has_house_aspiration_parameter = republic_agitation
				}
			}
			add = 15
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_communal }
			add = -20
		}
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					is_close_family_of = root
					is_spouse_of = root
				}
			}
			factor = 0
		}
	}
}

gdp_execution_approval_decree_decision = {
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { gdp_has_valid_indicted_character_trigger = yes }
				desc = gdp_execution_approval_decree_decision_named
			}
			desc = gdp_execution_approval_decree_decision
		}
	}
	desc = gdp_execution_approval_decree_decision_desc
	selection_tooltip = gdp_execution_approval_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes

	cooldown = { years = 5 }

	cost = {
		prestige = total_republic_decree_prestige_cost
	}

	is_shown = {
		government_has_flag = government_is_republic
		has_realm_law_flag = republic_execution_approval_required
		has_gdp_dlc_trigger = yes
	}

	is_valid_showing_failures_only = {
		gdp_is_assembly_head_trigger = yes
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
		gdp_has_valid_indicted_character_trigger = yes
		trigger_if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			custom_tooltip = {
				text = gained_assembly_approval_execution_desc
				NOT = { var:has_assembly_approval_execution ?= var:gdp_indicted_character }
			}
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		if = {
			limit = {
				var:gdp_indicted_character ?= { is_alive = yes }
			}
			var:gdp_indicted_character = { save_scope_as = indicted_character }
			custom_tooltip = {
				text = gdp_execution_approval_decree_decision_effect_desc
				set_variable = {
					name = has_assembly_approval_execution
					value = scope:indicted_character
				}
			}
		}
		else = {
			custom_tooltip = gdp_execution_approval_decree_decision_effect_no_indicted_desc
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { always = yes }

	ai_approval = {
		value = 0
		if = {
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
			add = ai_decree_approval_indicted_pledged_kin_value
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}
			add = {
				value = -20
				desc = LAW_BASE_RELUCTANCE_DESC
			}
			add = ai_decree_approval_punitive_reluctance_value
			add = ai_decree_approval_indicted_character_value
			add = ai_decree_approval_indicted_grounds_value
		}
		add = ai_decree_approval_indicted_kin_value
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		prestige >= total_republic_decree_prestige_cost
		var:gdp_indicted_character ?= {
			is_imprisoned_by = root
			root = { has_execute_reason = prev }
			save_temporary_scope_as = indicted_character
		}
		NOT = { gdp_has_any_punitive_approval_for_trigger = { TARGET = scope:indicted_character } }
	}

	ai_will_do = {
		base = 0
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					has_relation_rival = root
					has_relation_nemesis = root
				}
			}
			add = 30
		}
		modifier = {
			var:gdp_indicted_character = { save_temporary_scope_as = indicted_character }
			house_has_feud_relation_with_trigger = { TARGET = scope:indicted_character }
			add = 20
		}
		modifier = {
			OR = {
				gg_first_and_second_are_opposite_sides_trigger = { FIRST = root SECOND = var:gdp_indicted_character }
				gg_target_house_head_is_opposite_side_trigger = {
					ACTOR = root
					TARGET = var:gdp_indicted_character
				}
			}
			add = 20
		}
		modifier = {
			var:gdp_indicted_character = { has_claim_on = root.primary_title }
			add = 15
		}
		modifier = {
			OR = {
				has_trait = sadistic
				has_trait = vengeful
				has_trait = wrathful
				has_trait = callous
				has_trait = lunatic
			}
			add = 25
		}
		modifier = {
			has_trait = ambitious
			add = 10
		}
		modifier = {
			OR = {
				has_trait = compassionate
				has_trait = forgiving
			}
			add = -30
		}
		modifier = {
			has_trait = just
			add = -10
		}
		modifier = {
			gdp_is_republican_despot_or_supporter_trigger = yes
			add = 20
		}
		modifier = {
			gdp_character_in_democratic_republic_trigger = yes
			add = -20
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_signorial }
			add = 15
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_agitation }
			add = 15
		}
		modifier = {
			house ?= { has_house_aspiration_parameter = republic_communal }
			add = -20
		}
		modifier = {
			var:gdp_indicted_character = {
				OR = {
					is_adult = no
					is_close_family_of = root
					is_spouse_of = root
				}
			}
			factor = 0
		}
	}
}

# Overthrow Republican Government
gdp_overthrow_government_decision = {
	title = gdp_overthrow_government_decision 
	desc = gdp_overthrow_government_decision_desc
	selection_tooltip = gdp_overthrow_government_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/fractious.dds"
	}

	sort_order = 85
	decision_group_type = republic
	is_invisible = no
	
	cooldown = { years = 15 }

	cost = {
		gold = {
			value = major_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		liege != root
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		is_landless_ruler = yes
		custom_description = {
			text = has_patrician_rating_threshold_desc
			object = root
			value = gdp_patrician_house_score_threshold_3_value
			house ?= {
				house_power_score >= gdp_patrician_house_score_threshold_3_value
			}
		}
		prestige_level >= 3
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
	}

	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		item = { # Balanced
			value = agent_focus_balance
			current_description = overthrow_government_interaction.tt.agent_focus_balance
			localization = gdp_overthrow_agent_focus_balance
			icon = "gfx/interface/icons/schemes/icon_balanced_approach.dds"
			ai_chance = { value = 10 }
		}
		item = { # Success
			value = agent_focus_success
			current_description = overthrow_government_interaction.tt.agent_focus_success
			localization = gdp_overthrow_agent_focus_success
			icon = "gfx/interface/icons/schemes/icon_scheme_success.dds"
			ai_chance = { value = 10 }
		}
		item = { # Speed
			value = agent_focus_speed
			current_description = overthrow_government_interaction.tt.agent_focus_speed
			localization = gdp_overthrow_agent_focus_speed
			icon = "gfx/interface/icons/schemes/icon_scheme_speed.dds"
			ai_chance = { value = 10 }
		}
		item = { # Secrecy
			value = agent_focus_secrecy
			current_description = overthrow_government_interaction.tt.agent_focus_secrecy
			localization = gdp_overthrow_agent_focus_secrecy
			icon = "gfx/interface/icons/schemes/icon_secrecy.dds"
			ai_chance = { value = 10 }
		}
	}

	effect = {
		custom_tooltip = {
			text = overthrow_government_effect_tooltip
		}
		#Guelphs & Ghibellines
		gg_potential_catalyst_tooltip_effect = {
			ACTOR = root
			RECIPIENT = liege
			CATALYST = catalyst_gg_coup
		}
		send_interface_toast = {
			type = event_toast_effect_neutral
			title = start_overthrow_government_interaction
			left_icon = root
			right_icon = root.liege
			# Success.
			if = {
				limit = { scope:agent_focus_success = yes }
				begin_scheme_with_agents_effect = {
					SCHEME_TYPE = overthrow_government
					TARGET_TYPE = target_character
					TARGET_SCOPE = liege
					# Success.
					AGENT_1 = agent_conspirator
					AGENT_2 = agent_conspirator
					AGENT_3 = agent_demagogue
					# Speed.
					AGENT_4 = agent_financier
					# Secrecy.
					AGENT_5 = agent_commander
				}
			}
			# Speed.
			else_if = {
				limit = { scope:agent_focus_speed = yes }
				begin_scheme_with_agents_effect = {
					SCHEME_TYPE = overthrow_government
					TARGET_TYPE = target_character
					TARGET_SCOPE = liege
					# Speed.
					AGENT_1 = agent_financier
					AGENT_2 = agent_financier
					AGENT_3 = agent_financier
					# Success.
					AGENT_4 = agent_conspirator
					# Secrecy.
					AGENT_5 = agent_commander
				}
			}
			# Secrecy.
			else_if = {
				limit = { scope:agent_focus_secrecy = yes }
				begin_scheme_with_agents_effect = {
					SCHEME_TYPE = overthrow_government
					TARGET_TYPE = target_character
					TARGET_SCOPE = liege
					# Secrecy.
					AGENT_1 = agent_commander
					AGENT_2 = agent_commander
					AGENT_3 = agent_lookout
					# Success.
					AGENT_4 = agent_conspirator
					# Speed.
					AGENT_5 = agent_financier
				}
			}
			# Balanced.
			else = {
				begin_scheme_with_agents_effect = {
					SCHEME_TYPE = overthrow_government
					TARGET_TYPE = target_character
					TARGET_SCOPE = liege
					# Success.
					AGENT_1 = agent_conspirator
					AGENT_2 = agent_demagogue
					# Speed.
					AGENT_3 = agent_financier
					AGENT_4 = agent_financier
					# Secrecy.
					AGENT_5 = agent_commander
				}
			}
		}
	}
	
	requires_approve = { always = no }
	
	ai_approval = {
		value = 0
		add = {
			value = ai_compassion
			desc = player_facing_ai_compassion
		}
		if = {
			limit = {
				house ?= { has_house_aspiration_parameter = republic_communal }
			}
			add = {
				value = 10
				desc = REPUBLIC_COMMUNAL_AMBITION_DESC
			}
		}
		if = {
			limit = {
				house ?= { has_house_aspiration_parameter = republic_commerce }
			}
			add = {
				value = -10
				desc = REPUBLIC_COMMERCE_AMBITION_DESC
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 30
		kingdom = 30
		empire = 30
		hegemony = 0
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 10
		# Doge have more money
		modifier = {
			factor = 0.7
			root.gold > root.liege.gold
		}

		## House Relation modifier ##
		# Feuding
		modifier = {
			factor = 2
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = feud
				}
			}
		}
		# Rivalry
		modifier = {
			factor = 1.5
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = rivalry
				}
			}
		}
		# Quarreling
		modifier = {
			factor = 1.3
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = quarrel
				}
			}
		}
		# Cordial
		modifier = {
			factor = 0.5
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = cordial
				}
			}
		}
		# Friendly
		modifier = {
			factor = 0.3
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = friendly
				}
			}
		}
		# Faithful
		modifier = {
			factor = 0
			exists = root.liege.house
			root.house ?= {
				has_house_relation_with = root.liege.house
				any_house_relation = {
					any_relation_house = { root.liege.house ?= this }
					has_house_relation_level = amity
				}
			}
		}
		
		## Target's inclination towards the Ambition ##
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_commerce 
			}
			root.liege = {
				OR = {
					has_trait = impatient
					has_trait = wrathful
					has_trait = arbitrary
				}
			}
		}
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_aggrandizement
			}
			root.liege = {
				OR = {
					has_trait = humble
					has_trait = zealous
					has_trait = honest
				}
			} 
		}
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_communal
			}
			root.liege = {
				OR = {
					has_trait = arrogant
					has_trait = greedy
					has_trait = cynical
				}
			}
		}
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_signorial
			}
			root.liege = {
				OR = {
					has_trait = shy
					has_trait = humble
					has_trait = content
				}
			}
		}
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_agitation
			}
			root.liege = {
				OR = {
					has_trait = craven
					has_trait = calm
					has_trait = content
				}
			}
		}
		
		## The Government is unpopular ##
		modifier = {
			factor = 1.2
			root.liege = {
				capital_county = {
					popular_opinion = { -50 0 }
				}
			}
		}

		modifier = {
			factor = 2
			root.liege = {
				capital_county = {
					popular_opinion < -50
				}
			}
		}

		modifier = {
			factor = 0.5
			root.liege = {
				capital_county = {
					popular_opinion = { 25 50 }
				}
			}
		}

		modifier = {
			factor = 0.2
			root.liege = {
				capital_county = {
					popular_opinion > 50
				}
			}
		}
		
		## Control is low in the capital ##
		modifier = {
			factor = 1.2
			root.liege = {
				capital_county = {
					county_control < county_control_relative_25
				}
			}
		}

		modifier = {
			factor = 0.50
			root.liege = {
				capital_county = {
					county_control >= county_control_relative_25
					county_control <= county_control_baseline
				}
			}
		}
		modifier = {
			factor = 0.2
			root.liege = {
				capital_county = {
					county_control > county_control_relative_75
				}
			}
		}

		#The target is quite the GG meddler
		modifier = {
			add = {
				value = 0
				#More weight if they have high involvement, stacking
				if = {
					limit = { 
						root.liege = { 
							exists = var:gg_involvement
							var:gg_involvement >= gg_involvement_major_value
						}
					}
					add = 25
				}
				if = {
					limit = { 
						root.liege = { 
							exists = var:gg_involvement
							var:gg_involvement >= gg_involvement_massive_value
						}
					}
					add = 25
				}
				if = {
					limit = { 
						root.liege = { 
							exists = var:gg_involvement
							var:gg_involvement >= gg_involvement_omega_value
						}
					}
					add = 25
				}
				if = {
					limit = { 
						root.liege = { 
							exists = var:gg_involvement
							var:gg_involvement >= gg_involvement_capped_value
						}
					}
					add = 25
				}
				#Double that if the target GG ruler banished someone from your side
				if = {
					limit = { 
						root.liege = { has_character_modifier = vilified_ruler_modifier }
					}
					multiply = 2
				}
			}
			exists = situation:guelph_ghibelline
			gg_first_and_second_are_opposite_sides_trigger = { FIRST = root SECOND = root.liege }
		}
	}
}

# Renounce Family Title
gdp_renounce_noble_family_title_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/gdp_italian_market.dds"
	}
	sort_order = 80
	ai_check_interval = 0

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					government_has_flag = government_is_republic
					any_held_title = {
						is_noble_family_title = yes
						exists = current_heir
					}
				}
				desc = gdp_renounce_noble_family_title_decision_republic_desc
			}
			desc = gdp_renounce_noble_family_title_decision_republic_no_heir_desc
		}
	}
	selection_tooltip = gdp_renounce_noble_family_title_decision_tooltip
	decision_group_type = republic

	is_shown = {
		any_held_title = { is_noble_family_title = yes }
		government_has_flag = government_is_republic
		is_independent_ruler = no
		is_house_head = yes
		is_playable_character = yes
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		custom_tooltip = {
			text = renounce_noble_family_title_decision_tt.title
			any_held_title = { is_noble_family_title = yes }
		}
		custom_tooltip = {
			text = renounce_noble_family_title_decision_tt.heir
			any_held_title = {
				is_noble_family_title = yes
				current_heir ?= { is_available_ai_adult = yes }
			}
		}
		is_landed = no
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war_with_liege = no
	}

	effect = {
		if = {
			limit = { is_ai = no }
			random_held_title = {
				limit = { is_noble_family_title = yes }
				current_heir = { save_scope_as = new_player }
			}
		}
		show_as_tooltip = {
			add_character_modifier = { modifier = tgp_western_renounced_estate }
			custom_tooltip = renounce_noble_family_title_decision_tt
			if = {
				limit = { exists = scope:new_player }
				house = { set_house_head = scope:new_player }
				set_player_character = scope:new_player
			}
			tgp_step_down_title_recipient_tooltip_effect = yes
		}
		trigger_event = tgp_dynastic_cycle_decision_event.0101
		close_view = {
			view = decisions
			player = root
		}
	}

	cost = {
		prestige = minor_prestige_value
	}

	ai_potential = {
		is_at_war = no
		# Don't step down freely if you don't have any other house members holding a noble_family_title or inherit any held noble_family_title
		OR = {
			house ?= {
				any_house_member = {
					is_governor = yes
					top_liege = root.top_liege
				}
			}
			any_held_title = {
				tier = root.highest_held_title_tier
				is_noble_family_title = no
				current_heir.house = root.house
			}
		}
	}

	ai_will_do = {
		base = -10
		modifier = {
			add = 10
			has_trait = lazy
		}
		modifier = {
			add = 10
			has_trait = humble
		}
		modifier = {
			add = 10
			has_trait = content
		}
		modifier = {
			add = -100
			OR = {
				has_trait = ambitious
				has_trait = greedy
				has_trait = arrogant
			}
		}
	}
}

# Change Election Aspirations
change_republican_election_aspirations_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	}
	sort_order = 80
	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	desc = change_republican_election_aspirations_decision_desc
	selection_tooltip = change_republican_election_aspirations_decision_tooltip
	decision_group_type = republic

	is_shown = {
		government_has_flag = government_is_republic
		liege ?= { has_realm_law = republican_elective_succession_law }
		is_playable_character = yes
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		government_has_flag = government_is_republic
		trigger_if = { # Unavailable if you are the top liege - Unless if you have either modifier, so you may remove it.
			limit = { top_liege = this }
			OR = {
				has_character_modifier = gdp_republic_renounced_election_personal
				house ?= { has_house_modifier = gdp_republic_renounced_election_house }
			}
		}
		trigger_else = {
			custom_tooltip = { # The Capitano is your liege
				text = admin_confirmation_liege_tt
				liege ?= top_liege
				liege != root
			}
		}
		liege ?= { has_realm_law = republican_elective_succession_law }
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war_with_liege = no
		NOT = { top_liege ?= root }
	}

	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		### Remove yourself from elections & appointments
		item = {
			value = republic_renounced_election_personal
			is_valid = {
				NOR = {
					has_character_modifier = gdp_republic_renounced_election_personal
					house ?= { has_house_modifier = gdp_republic_renounced_election_house }
				}
				is_independent_ruler = no
				is_diarch = no
			}
			current_description = republic_renounced_election_personal_desc
			localization = republic_renounced_election_personal_name
			icon = "gfx/interface/icons/character_interactions/icon_liege.dds"
			ai_chance = {
				value = 0
				if = {
					limit = { has_trait = content }
					add = 100
				}
			}
		}
		### Make yourself available for elections & appointments
		item = {
			value = republic_desire_election_personal
			is_valid = {
				has_character_modifier = gdp_republic_renounced_election_personal
			}
			current_description = republic_desire_election_personal_desc
			localization = republic_desire_election_personal_name
			icon = "gfx/interface/icons/character_interactions/icon_liege.dds"
			ai_chance = {
				value = 0
				if = {
					limit = {
						has_character_modifier = gdp_republic_renounced_election_personal
						NOT = { has_trait = content }
					}
					add = 100
				}
			}
		}
		### Remove your house from elections & appointments
		item = {
			value = republic_renounced_election_house
			is_valid = {
				house ?= {
					custom_tooltip = {
						text = HOF_INTERACTION_IS_HOUSE_HEAD
						house_head ?= root
					}
					NOT = { has_house_modifier = gdp_republic_renounced_election_house }
				}
				NOT = { top_liege.house ?= root.house }
			}
			current_description = republic_renounced_election_house_desc
			localization = republic_renounced_election_house_name
			icon = "gfx/interface/icons/character_interactions/icon_dynasty.dds"
			ai_chance = {
				value = 0
			}
		}
		### Make your house available for elections & appointments
		item = {
			value = republic_desire_election_house
			is_valid = {
				house ?= {
					custom_tooltip = {
						text = HOF_INTERACTION_IS_HOUSE_HEAD
						house_head ?= root
					}
					has_house_modifier = gdp_republic_renounced_election_house
				}
			}
			current_description = republic_desire_election_house_desc
			localization = republic_desire_election_house_name
			icon = "gfx/interface/icons/character_interactions/icon_dynasty.dds"
			ai_chance = {
				value = 0
				if = {
					limit = {
						house ?= { has_house_modifier = gdp_republic_renounced_election_house }
					}
					add = 100
				}
			}
		}
	}

	effect = {
		if = {
			limit = {
				scope:republic_renounced_election_personal = yes
			}
			add_character_modifier = gdp_republic_renounced_election_personal
		}
		else_if = {
			limit = {
				scope:republic_desire_election_personal = yes
			}
			remove_character_modifier = gdp_republic_renounced_election_personal
		}
		else_if = {
			limit = {
				scope:republic_renounced_election_house = yes
			}
			house ?= {
				add_house_modifier = gdp_republic_renounced_election_house
			}
		}
		else_if = {
			limit = {
				scope:republic_desire_election_house = yes
			}
			house ?= {
				remove_house_modifier = gdp_republic_renounced_election_house
			}
		}
	}

	ai_potential = {
		OR = {
			has_character_modifier = gdp_republic_renounced_election_personal
			house ?= { has_house_modifier = gdp_republic_renounced_election_house }
			has_trait = content
		}
	}

	ai_will_do = {
		base = 20
		modifier = {
			add = 80
			OR = {
				has_character_modifier = gdp_republic_renounced_election_personal
				house ?= { has_house_modifier = gdp_republic_renounced_election_house }
			}
			NOT = { has_trait = content }
		}
	}
}

# Recruit trader
gdp_republic_recruit_talent_decision = {
	title = gdp_republic_recruit_talent_decision
	desc = gdp_republic_recruit_talent_decision_desc
	selection_tooltip = gdp_republic_recruit_talent_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/divided.dds"
	}

	sort_order = 65
	decision_group_type = republic

	cost = {
		prestige = medium_prestige_value
	}

	ai_check_interval = 0

	is_shown = {
		is_ai = no # Primarily a player tool
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_NOMAD_COURTIER_DECISION_NEXT_STEP_BUTTON"
		show_from_start = yes

		item = {
			value = gdp_republic_recruit_trader_competitiveness
			is_valid = {
			}
			current_description = gdp_republic_recruit_trader_competitiveness_desc
			localization = gdp_republic_recruit_trader_competitiveness_desc
			icon = "gfx/interface/icons/trade/icon_trade_competitiveness.dds"
			ai_chance = {
				value = 100
			}
		}
		item = {
			value = gdp_republic_recruit_trader_diplomacy
			is_valid = {
			}
			current_description = gdp_republic_recruit_trader_diplomacy_desc
			localization = gdp_republic_recruit_trader_diplomacy_desc
			icon = "gfx/interface/icons/trade/acumen.dds"
			ai_chance = {
				value = 100
			}
		}
		item = {
			value = gdp_republic_recruit_trader_capacity
			is_valid = {
			}
			current_description = gdp_republic_recruit_trader_capacity_desc
			localization = gdp_republic_recruit_trader_capacity_desc
			icon = "gfx/interface/icons/trade/icon_trade_capacity.dds"
			ai_chance = {
				value = 100
			}
		}
	}

	effect = {
		# Create a trader based on the selected template
		if = {
			limit = {
				scope:gdp_republic_recruit_trader_competitiveness = yes
			}
			custom_tooltip = {
				text = gdp_republic_recruit_trader_competitiveness_effect_desc
				create_character = {
					template = trader_martial_template
					culture = root.culture
					faith = root.faith
					dynasty = none
					location = root.capital_province
					save_scope_as = new_trader
				}
			}
		}
		else_if = {
			limit = {
				scope:gdp_republic_recruit_trader_diplomacy = yes
			}
			custom_tooltip = {
				text = gdp_republic_recruit_trader_diplomacy_effect_desc
				create_character = {
					template = trader_diplomacy_template
					culture = root.culture
					faith = root.faith
					dynasty = none
					location = root.capital_province
					save_scope_as = new_trader
				}
			}
		}
		else_if = {
			limit = {
				scope:gdp_republic_recruit_trader_capacity = yes
			}
			custom_tooltip = {
				text = gdp_republic_recruit_trader_capacity_effect_desc
				create_character = {
					template = trader_stewardship_template
					culture = root.culture
					faith = root.faith
					dynasty = none
					location = root.capital_province
					save_scope_as = new_trader
				}
			}
		}

		# Final additions to the trader, then add the trader to court
		if = {
			limit = { exists = scope:new_trader }

			if = {
				limit = {
					domicile ?= {
						domicile_location = {
							has_building_or_higher = republic_podesta_residence_01
						}
					}
				}
				scope:new_trader = {
					if = {
						limit = { scope:gdp_republic_recruit_trader_competitiveness = yes }
						add_martial_skill = 5
						add_intrigue_skill = 5
					}
					else_if = {
						limit = { scope:gdp_republic_recruit_trader_diplomacy = yes }
						add_diplomacy_skill = 5
						add_learning_skill = 5
					}
					else_if = {
						limit = { scope:gdp_republic_recruit_trader_capacity = yes }
						add_stewardship_skill = 6
					}
					rank_up_education_effect = yes
				}
			}

			send_interface_message = {
				type = send_interface_message
				title = gdp_republic_recruit_trader_recruited_t
				left_icon = scope:new_trader
				if = {
					limit = {
						scope:new_trader = {
							NOT = { is_courtier_of = root }
						}
					}
					add_courtier = scope:new_trader
				}
			}
		}
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 0
	}
}

# Clear the Great Plaza
gdp_republic_clear_great_plaza_decision = {
	title = gdp_republic_clear_great_plaza_decision
	desc = gdp_republic_clear_great_plaza_decision_desc
	selection_tooltip = gdp_republic_clear_great_plaza_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_decision_great_plaza.dds"
	}

	sort_order = 35
	decision_group_type = republic

	cost = {
	}

	is_shown = {
		is_ai = no # Primarily a player tool
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
		capital_province = {
			exists = great_district
			has_building_or_higher = pb_republic_city_hall_01
			county.holder = root
			great_district = {
				any_district_building = {
					is_primary_building = no
				}
			}
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
		gdp_is_planning_great_plaza_project_trigger = no
	}

	widget = {
		gui = "decision_view_widget_select_building"
		controller = select_scope_object
		decision_to_second_step_button = "CHOOSE_BUILDING_DECISION_NEXT_STEP_BUTTON"
		show_from_start = yes

		setup_items = {
			scope:actor = {
				capital_province = {
					great_district = {
						every_district_building = {
							limit = { is_primary_building = no }
							building_type = {
								add_to_list = item_list
							}
						}
					}
				}
			}
		}

		default_item = {
			scope:actor = {
				capital_province = {
					great_district = {
						random_district_building = {
							limit = { is_primary_building = no }
							building_type = {
								save_scope_as = selected_item
							}
						}
					}
				}
			}
		}

		ai_select_item = {
			scope:actor = {
				capital_province = {
					great_district = {
						random_district_building = {
							limit = { is_primary_building = no }
							building_type = {
								save_scope_as = selected_item
							}
						}
					}
				}
			}
		}
	}

	effect = {
		custom_tooltip = gdp_republic_clear_great_plaza_decision_warning
		send_interface_message = {
			type = send_interface_message
			title = gdp_republic_clear_great_plaza_decision_t
			left_icon = capital_county
			
			capital_province = {
				great_district = {
					remove_building = scope:selected_item
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 0
	}
}

# Meander through [CapitalName]
gdp_republic_city_stroll_decision = {
	picture = {
		trigger = {
			culture = { has_graphical_east_asia_culture_group_trigger = yes }
		}
		reference = "gfx/interface/illustrations/event_scenes/tgp_market_asia_crowd.dds"
	}
	picture = {
		trigger = {
			culture = { has_graphical_india_culture_group_trigger = yes }
		}
		reference = "gfx/interface/illustrations/event_scenes/gdp_artisans_street_india_crowd.dds"
	}
	picture = {
		trigger = {
			culture = { has_graphical_mena_culture_group_trigger = yes }
		}
		reference = "gfx/interface/illustrations/event_scenes/gdp_artisans_street_mena_crowd.dds"
	}
	picture = {
		trigger = {
			culture = { has_graphical_mediterranean_culture_group_trigger = yes }
			capital_province = { province_has_district = republic_great_plaza_district }
		}
		reference = "gfx/interface/illustrations/decisions/gdp_decision_great_plaza.dds"
	}
	picture = {
		trigger = {
			culture = { has_graphical_mediterranean_culture_group_trigger = yes }
		}
		reference = "gfx/interface/illustrations/event_scenes/gdp_italian_market_crowd.dds"
	}
	picture = {
		trigger = {
			culture = { has_graphical_iberian_culture_group_trigger = yes }
		}
		reference = "gfx/interface/illustrations/event_scenes/market_east_crowd.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/market_west_crowd.dds"
	}
	sort_order = 85
	ai_check_interval_by_tier = {
		barony = 180
		county = 120
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = gdp_republic_city_stroll_decision_desc
	selection_tooltip = gdp_republic_city_stroll_decision_tooltip
	decision_group_type = republic
	
	cooldown = { years = 5 }

	is_shown = {
		# You are a patrician
		government_has_flag = government_is_republic
		is_landless_ruler = yes
		is_independent_ruler = no
		has_gdp_dlc_trigger = yes
	}

	is_valid = {}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		NOT = {
			capital_county ?= {
				has_province_with_epidemic = { intensity = any }
			}
		}
	}

	effect = {
		custom_tooltip = {
			text = city_stroll_effect_tooltip
			trigger_event = { on_action = patrician_stroll_on_action }
		}
		add_character_modifier = {
			modifier = gdp_out_and_about_modifier
			years = 5
		}
	}

	ai_potential = {
		government_has_flag = government_is_republic
		is_landless_ruler = yes
		is_independent_ruler = no
		is_adult = yes
		is_imprisoned = no
	}

	ai_will_do = {
		base = 10
		modifier = {
			factor = 1.3
			root.house = {
				has_house_aspiration_parameter = republic_aggrandizement
			}
			root.liege = {
				OR = {
					has_trait = humble
					has_trait = zealous
					has_trait = honest
				}
			} 
		}
		## Control is not low in the capital ##
		modifier = {
			factor = 1.2
			root.liege = {
				capital_county = {
					county_control < 75
				}
			}
		}
		modifier = {
			factor = 0.50
			root.liege = {
				capital_county = {
					county_control = { 25 50 } 
				}
			}
		}
		modifier = {
			factor = 0.2
			root.liege = {
				capital_county = {
					county_control > 25
				}
			}
		}	
	}
}

# Leverage Trade Posts in Market
gdp_improve_trade_post_market_decision = {
	title = gdp_improve_trade_post_market_decision
	desc = gdp_improve_trade_post_market_decision_desc
	picture = {
		reference = "gfx/interface/illustrations/decisions/fractious.dds"
	}

	sort_order = 40
	decision_group_type = trade

	cost = {
		prestige = massive_prestige_value
	}

	is_shown = {
		# You have the needed legacy
		dynasty ?= { has_dynasty_perk = gdp_republic_legacy_2 }

		# You have Trade Posts
		government_allows = trade_post

		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		trade_post_count >= 1
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		trigger_if = {
			limit = { exists = scope:selected_item }
			scope:selected_item = {
				gdp_can_leverage_trade_posts_in_market_trigger = { CHARACTER = root }
			}
		}
	}

	widget = {
		gui = "decision_view_widget_select_trade_market"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT_TRADE_MARKET"

		setup_items = {
			scope:actor = {
				if = {
					limit = {
						trade_post_count > 0
					}
					every_owned_trade_post_district = {
						district_province = {
							barony = {
								trade_market = {
									if = {
										limit = {
											NOT = { is_in_list = item_list }
										}
										add_to_list = item_list
									}
								}
							}
						}
					}
				}
				else = { # We add the capital's market as a fallback, so that the effects remains visible even without trade posts
					capital_barony.trade_market = { add_to_list = item_list }
				}
			}
		}

		default_item = {
			scope:actor = {
				ordered_owned_trade_post_district = {
					limit = {
						district_province.barony.trade_market = {
							gdp_can_leverage_trade_posts_in_market_trigger = { CHARACTER = scope:actor }
						}
					}
					district_province.barony.trade_market = { save_scope_as = selected_item }
				}
			}
		}

		is_item_valid = {
			gdp_can_leverage_trade_posts_in_market_trigger = { CHARACTER = scope:actor }
		}

		ai_select_item = {
			scope:actor = {
				if = {
					limit = {
						any_owned_trade_post_district = {
							district_province.barony = {
								this = scope:actor.capital_barony
								trade_market = {
									gdp_can_leverage_trade_posts_in_market_trigger = { CHARACTER = scope:actor }
								}
							}
						}
					}
					capital_barony.trade_market = { save_scope_as = selected_item }
				}
				else = {
					random_owned_trade_post_district = {
						limit = {
							district_province.barony.trade_market = {
								gdp_can_leverage_trade_posts_in_market_trigger = { CHARACTER = scope:actor }
							}
						}
						district_province.barony.trade_market = { save_scope_as = selected_item }
					}
				}
			}
		}
	}

	effect = {
		scope:selected_item = { save_scope_as = selected_trade_market }
		
		# Save the number of trade posts owned within the trade market
		save_scope_value_as = {
			name = owned_trade_posts
			value = {
				value = 0
				every_owned_trade_post_district = {
					limit = {
						district_province.barony.trade_market = scope:selected_trade_market
					}
					add = 1
				}
			}
		}

		# Apply modifier to market
		scope:selected_trade_market = {
			add_competitiveness_modifier_for_character = {
				character = root
				modifier = gdp_dominate_market_trade_post_modifier
			}
		}
		custom_tooltip = gdp_improve_trade_post_market_decision_effect_desc
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
		prestige >= massive_prestige_value
	}

	ai_will_do = {
		base = 100
	}
}

# Organize Charity in Trade Posts
gdp_trade_post_charity_decision = {
	title = gdp_trade_post_charity_decision
	desc = gdp_trade_post_charity_decision_desc
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}

	sort_order = 40
	decision_group_type = trade

	cooldown = { years = 10 }

	cost = {
		prestige = massive_prestige_value
	}

	is_shown = {
		# You have the ambition to gain the decision
		house ?= { has_house_aspiration_parameter = ambition_unlock_trade_post_charity_decision }

		# You have Trade Posts
		government_allows = trade_post

		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		trade_post_count >= 1
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		# Save the number of trade posts we own
		save_scope_value_as = {
			name = owned_trade_posts
			value = trade_post_count
		}

		# Apply the modifier
		add_character_modifier = {
			modifier = gdp_trade_post_charity_modifier
			years = 10
		}

		# Gain opinion with county holders where you have trade posts
		every_owned_trade_post_district = {
			limit = {
				district_province = {
					county = {
						holder = {
							this != root
						}
					}
				}
			}
			custom = every_trade_post_county_holder_tt
			district_province.county.holder = {
				add_opinion = {
					modifier = grateful_opinion
					target = root
					opinion = 10
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
		prestige >= massive_prestige_value
	}

	ai_will_do = {
		base = 100
	}
}

# Gather Popular Support
gdp_gather_popular_support_decision = {
	title = gdp_gather_popular_support_decision
	desc = gdp_gather_popular_support_decision_desc
	picture = {
		reference = "gfx/interface/illustrations/event_story/gdp_republican.dds"
	}

	sort_order = 40
	decision_group_type = republic

	cooldown = { years = 10 }

	cost = {
		prestige = massive_prestige_value
	}

	is_shown = {
		# You have the needed legacy
		dynasty ?= { has_dynasty_perk = gdp_republic_legacy_5 }
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		capital_county ?= {
			popular_opinion > 0
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
	}

	effect = {
		# Personal modifier
		add_character_modifier = {
			modifier = gdp_gather_popular_support_modifier
			years = 10
		}

		# Clear out any existing modifiers
		hidden_effect = {
			house ?= {
				if = {
					limit = { has_house_modifier = gdp_gather_popular_support_house_t3_modifier }
					remove_house_modifier = gdp_gather_popular_support_house_t3_modifier
				}
				if = {
					limit = { has_house_modifier = gdp_gather_popular_support_house_t2_modifier }
					remove_house_modifier = gdp_gather_popular_support_house_t2_modifier
				}
				if = {
					limit = { has_house_modifier = gdp_gather_popular_support_house_t1_modifier }
					remove_house_modifier = gdp_gather_popular_support_house_t1_modifier
				}
			}
		}

		# Add new house modifier
		if = {
			limit = {
				capital_county.popular_opinion >= 80
			}
			house ?= {
				add_house_modifier = {
					modifier = gdp_gather_popular_support_house_t3_modifier
					years = 15
				}
			}
		}
		else_if = {
			limit = {
				capital_county.popular_opinion >= 50
			}
			house ?= {
				add_house_modifier = {
					modifier = gdp_gather_popular_support_house_t2_modifier
					years = 15
				}
			}
		}
		else = {
			house ?= {
				add_house_modifier = {
					modifier = gdp_gather_popular_support_house_t1_modifier
					years = 15
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
		gdp_is_patrician_trigger = yes
		prestige >= massive_prestige_value
		# AI doesn't have to bother until popular opinion is at least somewhat high
		capital_county ?= {
			popular_opinion > 30
		}
	}

	ai_will_do = {
		base = 25
	}
}

# AI ONLY - Decision to get rid of trade posts/patricians a ruler doesn't like in their domain
# Players use oust_trade_post_interaction
gdp_oust_from_trade_post_decision = {
	# Since it's AI only, actual loc is not needed - Reuses loc from the interaction
	title = oust_trade_post_interaction
	desc = oust_trade_post_interaction
	selection_tooltip = oust_trade_post_interaction
	confirm_text = oust_trade_post_interaction
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_trade_ships.dds"
	}
	sort_order = 20

	cost = {
	}

	is_shown = {
		is_ai = yes
		is_landed = yes
		any_held_title = {
			tier = tier_county
			any_county_province = {
				exists = trade_post_district
				trade_post_owner = {
					NOT = { has_hook = root }
					OR = {
						NOT = { is_vassal_or_below_of = root }
						AND = {
							is_vassal_or_below_of = root
							root = {
								can_have_trade_posts = no
								has_realm_law_flag = title_revocation_allowed
							}
						}
					}
					OR = {
						has_relation_rival = root
						house ?= {
							any_house_relation = {
								any_relation_house = { root.house ?= this }
								OR = {
									has_house_relation_level = feud
									has_house_relation_level = rivalry
								}
							}
						}
						reverse_opinion = {
							target = root
							value < -50
						}
					}
				}
			}
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
		}
	}

	effect = {
		save_scope_as = actor
		random_held_title = {
			limit = {
				tier = tier_county
				any_county_province = {
					exists = trade_post_district
					trade_post_owner = {
						NOT = { has_hook = root }
						OR = {
							NOT = { is_vassal_or_below_of = root }
							AND = {
								is_vassal_or_below_of = root
								root = {
									can_have_trade_posts = no
									has_realm_law_flag = title_revocation_allowed
								}
							}
						}
						OR = {
							has_relation_rival = root
							house ?= {
								any_house_relation = {
									any_relation_house = { root.house ?= this }
									OR = {
										has_house_relation_level = feud
										has_house_relation_level = rivalry
									}
								}
							}
							reverse_opinion = {
								target = root
								value < -50
							}
						}
					}
					save_temporary_scope_as = target_trade_post_province
				}
			}
			scope:target_trade_post_province ?= {
				county = { save_scope_as = trade_post_target_county }
				trade_post_district = { save_scope_as = target }
				show_as_tooltip = {
					remove_district_type = trade_post_location_district
				}
				trade_post_owner = {
					save_scope_as = recipient
					trigger_event = republic_event.0012
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 48
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_potential = {
		NOR = {
			has_trait = forgiving
			AND = {
				has_trait = compassionate
				has_trait = content
			}
		}
	}

	ai_will_do = {
		base = 50

		## Traits
		modifier = {
			has_trait = vengeful
			add = 20
		}
		modifier = {
			has_trait = paranoid
			add = 10
		}
		modifier = {
			has_trait = callous
			add = 10
		}
		modifier = {
			has_trait = stubborn
			add = 10
		}
		modifier = {
			has_trait = trusting
			add = -10
		}
		modifier = {
			has_trait = just
			add = -10
		}
		modifier = {
			has_trait = craven
			add = -10
		}
	}
}

### DECREES ###
# Give Alms in Capital - Use treasury funds to give alms to the poor
gdp_fund_alms_decree_decision = {
	title = gdp_fund_alms_decree_decision
	desc = gdp_fund_alms_decree_decision_desc
	selection_tooltip = gdp_fund_alms_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 15 }

	cost = {
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		# You are the doge
		custom_tooltip = {
			text = you_are_republic_leader_desc
			this = highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		capital_province ?= {
			add_province_modifier = {
				modifier = gdp_fund_alms_decree_modifier
				years = 10
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			add = {
				value = ai_compassion
				desc = player_facing_ai_compassion
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_communal }
				}
				add = {
					value = 10
					desc = REPUBLIC_COMMUNAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = -10
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}
		}
	}

	ai_potential = {
		this = liege # I.e. is independent
		treasury > massive_treasury_value
	}

	ai_will_do = {
		base = 0
		modifier = {
			capital_province.county ?= {
				popular_opinion < -25
			}
			add = 10
		}
		modifier = {
			capital_province.county ?= {
				popular_opinion < -50
			}
			add = 10
		}
		modifier = {
			capital_province.county ?= {
				popular_opinion < -75
			}
			add = 10
		}
		modifier = {
			piety_level >= 2
			add = {
				value = piety_level
				multiply = 4
			}
		}
	}
}

# Tax Holiday - Remit city taxes to boost popular opinion
gdp_tax_holiday_decree_decision = {
	title = gdp_tax_holiday_decree_decision
	desc = gdp_tax_holiday_decree_decision_desc
	selection_tooltip = gdp_tax_holiday_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI

	cooldown = { years = 10 }

	cost = {
		prestige = total_republic_decree_prestige_cost
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		custom_tooltip = {
			text = you_are_republic_leader_desc
			this = highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		capital_county ?= {
			add_county_modifier = {
				modifier = gdp_tax_holiday_decree_modifier
				years = 10
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }

	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_communal }
				}
				add = {
					value = 15
					desc = REPUBLIC_COMMUNAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = -15
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_signorial }
				}
				add = {
					value = -15
					desc = REPUBLIC_SIGNORIAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_agitation }
				}
				add = {
					value = -10
					desc = REPUBLIC_AGITATION_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_aggrandizement }
				}
				add = {
					value = -10
					desc = REPUBLIC_AGGRANDIZEMENT_AMBITION_DESC
				}
			}
			if = {
				limit = { has_trait = generous }
				add = {
					value = 10
					desc = LAW_TRAIT_GENEROUS_DESC
				}
			}
			if = {
				limit = { has_trait = greedy }
				add = {
					value = -10
					desc = LAW_TRAIT_GREEDY_DESC
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 0
		modifier = {
			capital_county ?= {
				popular_opinion < -15
			}
			add = 15
		}
		modifier = {
			capital_county ?= {
				popular_opinion < -40
			}
			add = 20
		}
		modifier = {
			capital_county ?= {
				popular_opinion < -65
			}
			add = 20
		}
		modifier = {
			has_trait = generous
			add = 10
		}
		modifier = {
			has_trait = greedy
			factor = 0.3
		}
	}
}

# Debt Forgiveness - Cancel citizen debts to boost popular opinion at the cost of patrician goodwill
gdp_debt_forgiveness_decree_decision = {
	title = gdp_debt_forgiveness_decree_decision
	desc = gdp_debt_forgiveness_decree_decision_desc
	selection_tooltip = gdp_debt_forgiveness_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/concerted.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI

	cooldown = { years = 15 }

	cost = {
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		custom_tooltip = {
			text = you_are_republic_leader_desc
			this = highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		capital_county ?= {
			add_popular_opinion = 50
		}
		every_vassal = {
			custom = gdp_debt_forgiveness_upset_patricians_tt
			limit = {
				NOT = {
					house ?= { has_house_aspiration_parameter = republic_communal }
				}
			}
			add_opinion = {
				modifier = wasted_treasury_opinion
				target = root
				opinion = -20
			}
		}
		every_vassal = {
			custom = gdp_debt_forgiveness_pleased_patricians_tt
			limit = {
				house ?= { has_house_aspiration_parameter = republic_communal }
			}
			add_opinion = {
				modifier = political_ally_opinion
				target = root
				opinion = 15
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }

	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_communal }
				}
				add = {
					value = 20
					desc = REPUBLIC_COMMUNAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = -15
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_signorial }
				}
				add = {
					value = -20
					desc = REPUBLIC_SIGNORIAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_aggrandizement }
				}
				add = {
					value = -10
					desc = REPUBLIC_AGGRANDIZEMENT_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_agitation }
				}
				add = {
					value = -10
					desc = REPUBLIC_AGITATION_AMBITION_DESC
				}
			}
			if = {
				limit = { has_trait = generous }
				add = {
					value = 10
					desc = LAW_TRAIT_GENEROUS_DESC
				}
			}
			if = {
				limit = { has_trait = greedy }
				add = {
					value = -15
					desc = LAW_TRAIT_GREEDY_DESC
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		treasury > massive_treasury_value
	}

	ai_will_do = {
		base = 0
		modifier = {
			capital_county ?= {
				popular_opinion < -25
			}
			add = 15
		}
		modifier = {
			capital_county ?= {
				popular_opinion < -50
			}
			add = 20
		}
		modifier = {
			capital_county ?= {
				popular_opinion < -75
			}
			add = 20
		}
		modifier = {
			has_trait = generous
			add = 10
		}
		modifier = {
			has_trait = greedy
			factor = 0.2
		}
	}
}

# Finance War Effort
gdp_finance_war_decree_decision = {
	title = gdp_finance_war_decree_decision
	desc = gdp_finance_war_decree_decision_desc
	selection_tooltip = gdp_finance_war_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_siege_warfare.dds"
	}

	sort_order = 21
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 5 }

	cost = {
		prestige = total_republic_decree_prestige_cost
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		# You are the doge
		OR = {
			this = liege
			liege = {
				NOT = { government_has_flag = government_is_republic }
			}
		}
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		is_at_war = yes
		treasury <= 0
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}
	
	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		item = { # Patrician Tax
			value = finance_war_patrician_tax
			
			current_description = finance_war_patrician_tax_desc
			localization = finance_war_patrician_tax_name
			icon = "gfx/interface/icons/government_types/republic_government.dds"
			ai_chance = {
				value = 10
				if = {
					limit = {
						house ?= { has_house_aspiration_parameter = republic_communal }
					}
					multiply = 0
				}
			}
		}
		item = { # Citizen Tax
			value = finance_war_citizen_tax
			
			current_description = finance_war_citizen_tax_desc
			localization = finance_war_citizen_tax_name
			icon = "gfx/interface/icons/character_interactions/loan_money_interaction.dds"
			ai_chance = {
				value = 10
				if = {
					limit = {
						house ?= { has_house_aspiration_parameter = republic_signorial }
					}
					multiply = 0
				}
			}
		}
	}

	effect = {
		if = {
			limit = {
				scope:finance_war_patrician_tax = yes
			}
			every_vassal_or_below = {
				custom = every_patrician_tt
				limit = {
					any_held_title = {
						is_noble_family_title = yes
					}
				}
				pay_gold_to_treasury = {
					target = root
					value = root.medium_gold_value
				}
				add_opinion = {
					modifier = upset_opinion
					target = root
					opinion = -15
				}
			}
			show_as_tooltip = { # So that you can see the total gain
				add_treasury = {
					value = 0
					every_vassal_or_below = {
						limit = {
							any_held_title = {
								is_noble_family_title = yes
							}
						}
						add = root.medium_gold_value
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:finance_war_citizen_tax = yes
			}
			add_treasury = {
				value = 0
				every_sub_realm_county = {
					add = prosperity_level
				}
				multiply = 10
			}
			every_sub_realm_county = {
				custom = every_county
				add_county_modifier = {
					modifier = gdp_taxed_county_modifier
					years = 10
				}
				change_prosperity_level = -1
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_assembly_preparation_approval_value
			add = republic_caucus_room_approval_value
			add = {
				value = ai_boldness
				desc = player_facing_ai_boldness
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_signorial }
				}
				add = {
					value = 10
					desc = REPUBLIC_SIGNORIAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_aggrandizement }
				}
				add = {
					value = 10
					desc = REPUBLIC_AGGRANDIZEMENT_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = -20
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}
			
			if = {
				limit = {
					has_trait = arrogant
				}
				add = {
					value = 20
					desc = LAW_TRAIT_ARROGANT_DESC
				}
			}
			if = {
				limit = {
					has_trait = arbitrary
				}
				add = {
					value = 20
					desc = LAW_TRAIT_ARBITRARY_DESC
				}
			}
			if = {
				limit = {
					has_trait = just
				}
				add = {
					value = -20
					desc = LAW_TRAIT_JUST_DESC
				}
			}
			if = {
				limit = {
					has_trait = greedy
					scope:finance_war_patrician_tax = yes
				}
				add = {
					value = -30
					desc = LAW_TRAIT_GREEDY_DESC
				}
			}
			if = {
				limit = {
					has_trait = compassionate
					scope:finance_war_citizen_tax = yes
				}
				add = {
					value = -30
					desc = LAW_TRAIT_COMPASSIONATE_DESC
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		is_at_war = yes
		OR = {
			treasury_debt_level >= 2
			AND = {
				has_trait = greedy
				treasury_debt_level > 0
			}
		}
	}

	ai_will_do = {
		base = 0
		modifier = {
			ai_boldness > 0
			add = {
				value = ai_boldness
				multiply = 0.25
			}
		}
		modifier = {
			ai_rationality < 0
			add = {
				value = ai_rationality
				multiply = -0.2
			}
		}
	}
}

# Request War Approval - Ask the assembly for permission to wage war
gdp_war_approval_decree_decision = {
	title = gdp_war_approval_decree_decision
	desc = gdp_war_approval_decree_decision_desc
	selection_tooltip = gdp_war_approval_decree_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}

	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 5 }

	cost = {
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		# Permission from the assembly is required by law
		has_realm_law_flag = republic_war_approval_required
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		custom_tooltip = {
			text = gained_assembly_approval_declare_war_desc
			NOT = { has_variable = has_assembly_approval_declare_war }
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		custom_tooltip = {
			text = gdp_war_approval_decree_decision_effect_desc
			set_variable = {
				name = has_assembly_approval_declare_war
				value = yes
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}

	requires_approve = { always = yes }

	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				liege ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}
			
			# House ambitions
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = -20
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}

			# Vassal stances
			if = {
				limit = {
					is_ruler = yes
					liege != this
					has_vassal_stance = glory_hound
				}
				add = {
					value = 20
					desc = LAW_VASSAL_STANCE_DESC
				}
			}
			if = {
				limit = {
					is_ruler = yes
					liege != this
					has_vassal_stance = belligerent
				}
				add = {
					value = 10
					desc = LAW_VASSAL_STANCE_DESC
				}
			}
			if = {
				limit = {
					is_ruler = yes
					liege != this
					has_vassal_stance = parochial
				}
				add = {
					value = -20
					desc = LAW_VASSAL_STANCE_DESC
				}
			}
		}
	}

	ai_potential = {
		this = liege # I.e. is independent
		treasury > massive_treasury_value
		ai_has_cautious_personality = no
	}

	ai_will_do = {
		base = 10
		modifier = {
			OR = {
				has_trait = ambitious
				has_trait = brave
				has_trait = greedy
				has_trait = wrathful
			}
			add = 20
		}
		modifier = {
			ai_has_warlike_personality = yes
			add = 20
		}
	}
}

# Quarantine Ships decree
gdp_quarantine_ship_decree_decision = {
	title = gdp_quarantine_ship_decree_decision
	desc = gdp_quarantine_ship_decree_decision_desc
	selection_tooltip = gdp_quarantine_ship_decree_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_great_project.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_trade_ships.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 5 }

	cost = {
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		# You are the doge
		custom_tooltip = {
			text = you_are_republic_leader_desc
			this = highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		capital_county ?= {
			add_county_modifier = {
				modifier = gdp_trentina_quarantine_county_modifier
				years = 5
			}
		}
		capital_barony ?= {	
			trade_market = {
				every_trade_route_in_market = {
					custom = gdp_quarantine_modifier_desc
					trade_route_owner = {
						add_character_modifier = {
							modifier = gdp_trentina_quarantine_character_modifier
							years = 5
						}
					}	
				}	
			}
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				highest_liege_matching_rule:uses_assembly ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}

			if = {
				limit = {
					any_realm_county = {
						any_county_province_epidemic = {
							outbreak_intensity = apocalyptic
						}
					}
				}
				add = {
					value = 25
					desc = DECREE_PLAGUE_APOCALYPTIC_DESC
				}
			}
			else_if = {
				limit = {
					any_realm_county = {
						any_county_province_epidemic = {
							outbreak_intensity = major
						}
					}
				}
				add = {
					value = 10
					desc = DECREE_PLAGUE_MAJOR_DESC
				}
			}
			else_if = {
				limit = {
					any_realm_county = {
						any_county_province_epidemic = {
							outbreak_intensity = minor
						}
					}
				}
				add = {
					value = 5
					desc = DECREE_PLAGUE_MINOR_DESC
				}
			}			
			else = {
				add = {
					value = -30
					desc = DECREE_PLAGUE_NONE_DESC
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		treasury > massive_treasury_value
	}

	ai_will_do = {
		base = 0
		## how resistant is the capital already?
		modifier = {
			capital_province = {
				epidemic_resistance >= 6
			}
			factor = 0.5
		}
		## Decease is threatening the republic
		modifier = {
			any_sub_realm_county = {
				any_county_province_epidemic = {
					outbreak_intensity = apocalyptic
				}
			}
			add = 80
		}

		modifier = {
			any_sub_realm_county = {
				any_county_province_epidemic = {
					outbreak_intensity = major
				}
			}
			add = 40
		}

		modifier = {
			any_sub_realm_county = {
				any_county_province_epidemic = {
					outbreak_intensity = major
				}
			}
			add = 20
		}	
		## Traits
		modifier = {
			has_trait = paranoid
			factor = 1.5

		}
		modifier = {
			has_trait = lifestyle_herbalist
			factor = 1.3
		}
		modifier = {
			has_trait = lifestyle_physician
			factor = 1.6
		}
		modifier = {
			has_trait = greedy
			factor = 0.8
		}
	}
}

# Enforce Curfew decree
gdp_enforce_curfew_decree_decision = {
	title = gdp_enforce_curfew_decree_decision
	desc = gdp_enforce_curfew_decree_decision_desc
	selection_tooltip = gdp_enforce_curfew_decree_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_great_project.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_prison.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 5 }

	cost = {
		prestige = total_republic_decree_prestige_cost
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes	
	}

	is_valid = {
		# You are the doge
		custom_tooltip = {
			text = you_are_republic_leader_desc
			this = highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		add_character_modifier = {
			modifier = gdp_curfew_character_modifier
			years = 5
		}
		every_vassal = {
			limit = {
				capital_county = root.capital_county
			}
			custom = gdp_republic_curfew_desc
			add_character_modifier = {
				modifier = gdp_curfew_character_modifier
				years = 5
			}
		}
		capital_county = {
			change_county_control = 10	
		}
		gdp_consume_republic_assembly_preparation_effect = yes
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				highest_liege_matching_rule:uses_assembly ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = yes
		treasury > major_treasury_value
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 10
		## Order in the city
		modifier = {
			capital_county = {
				county_control < county_control_baseline
			}
			add = 40
		}
		## Traits
		modifier = {
			has_trait = diligent
			factor = 1.4
		}
		modifier = {
			has_trait = paranoid
			factor = 2
		}
		modifier = {
			has_trait = zealous
			factor = 1.5
		}
		modifier = {
			OR = {
				has_trait = deceitful
				has_trait = lustful
			}
			factor = 0.5
		}
	}
}

# Sponsor Craft Guilds to boost prosperity
gdp_sponsor_craft_guild_decision = {
	title = gdp_sponsor_craft_guild_decision
	desc = gdp_sponsor_craft_guild_decision_desc
	selection_tooltip = gdp_sponsor_craft_guild_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_great_project.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/cooperative.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 10 }

	cost = {
		prestige = total_republic_decree_prestige_cost
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 150
		duchy = 120
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes
	}

	is_valid = {
		# You are not the doge
		custom_tooltip = {
			text = you_are_not_republic_leader_desc
			this != highest_liege_matching_rule:uses_assembly
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		capital_province.county = {
			add_county_modifier = {
				modifier = gdp_sponsored_guild_modifier
				years = 5
			}
		}
		house ?= {
			add_house_modifier = {
				modifier = gdp_guild_sponsor_house_modifier
				years = 10
			}
		}
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				scope:enactor ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}

			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_commerce }
				}
				add = {
					value = 10
					desc = REPUBLIC_COMMERCE_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_communal }
				}
				add = {
					value = 5
					desc = REPUBLIC_COMMUNAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_agitation }
				}
				add = {
					value = -20
					desc = REPUBLIC_AGITATION_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_signorial }
				}
				add = {
					value = -5
					desc = REPUBLIC_SIGNORIAL_AMBITION_DESC
				}
			}
			if = {
				limit = {
					house ?= { has_house_aspiration_parameter = republic_aggrandizement }
				}
				add = {
					value = -15
					desc = REPUBLIC_AGGRANDIZEMENT_AMBITION_DESC
				}
			}
			if = {
				limit = { has_trait = education_stewardship }
				add = {
					value = 50
					desc = gdp_stewardship_education_approval_desc
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = no
		treasury > major_treasury_value
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 10
		## Traits
		modifier = {
			has_trait = diligent
			factor = 1.5
		}
		modifier = {
			has_trait = ambitious
			factor = 1.5
		}
		modifier = {
			has_lifestyle = stewardship_lifestyle
			factor = 2
		}
	}
}

# Request a Noble Magistracy for your heir
gdp_request_noble_magistracy_decision = {
	title = gdp_request_noble_magistracy_decision
	desc = gdp_request_noble_magistracy_decision_desc
	selection_tooltip = gdp_request_noble_magistracy_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_house_fief.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/concerted.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 6 }

	cost = {
		prestige = total_republic_decree_prestige_cost
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 150
		duchy = 120
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes	
	}

	is_valid = {
		# You are the doge
		custom_tooltip = {
			text = you_are_not_republic_leader_desc
			this != highest_liege_matching_rule:uses_assembly
		}
		custom_tooltip = {
			text = you_have_and_adult_heir_desc
			any_held_title = {
				is_noble_family_title = yes
				current_heir ?= {
					is_available_quick = {
						adult = yes
						at_war = no
						imprisoned = no
						incapable = no
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		random_held_title = {
			limit = { is_noble_family_title = yes }
			current_heir = {
				add_character_modifier = {
					modifier = gdp_noble_magistrate_modifier
					years = 5
				} 
			}
		}
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				scope:enactor ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}

			if = {
				limit = {
					exists = scope:enactor.player_heir
					NOT = { this = scope:enactor.player_heir }
				}
				add = {
					value = "opinion(scope:enactor.player_heir)"
					desc = gdp_noble_heir_opinion_approval_desc
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = no
		treasury > major_treasury_value
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 10
		## Order in the city
		modifier = {
			capital_county = {
				county_control < county_control_baseline
			}
			add = 40
		}
		## Traits
		modifier = {
			has_trait = diligent
			factor = 1.4
		}
		modifier = {
			has_trait = paranoid
			factor = 2
		}
		modifier = {
			has_trait = zealous
			factor = 1.5
		}
		modifier = {
			OR = {
				has_trait = deceitful
				has_trait = lustful
			}
			factor = 0.5
		}
	}
}

# Request that your private debt be paid through the treasury
gdp_request_relief_from_bankruptcy_decision = {
	title = gdp_request_relief_from_bankruptcy_decision
	desc = gdp_request_relief_from_bankruptcy_decision_desc
	selection_tooltip = gdp_request_relief_from_bankruptcy_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_debate.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/independent.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 5 }

	cost = {
		prestige = total_republic_decree_prestige_cost
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 150
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes	
	}

	is_valid = {
		# Personal gold is negative. Use gold, not short_term_gold.
		custom_tooltip = {
			text = negative_gold_balance_desc
			gold < 0
		}
		# You are not the doge
		custom_tooltip = {
			text = you_are_not_republic_leader_desc
			this != highest_liege_matching_rule:uses_assembly
		}
		custom_tooltip = {
			text = the_treasury_can_cover_your_debt_desc
			highest_liege_matching_rule:uses_assembly = {
				gdp_is_assembly_head_trigger = yes
				treasury >= {
					value = root.gold
					multiply = -1
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		gdp_save_patrician_liege_effect = yes
		if = {
			limit = {
				gold < 0
				exists = highest_liege_matching_rule:uses_assembly
				NOT = { this = highest_liege_matching_rule:uses_assembly }
				highest_liege_matching_rule:uses_assembly = {
					treasury >= {
						value = root.gold
						multiply = -1
					}
				}
			}
			# One positive snapshot, shared by both sides
			save_scope_value_as = {
				name = bankruptcy_relief
				value = {
					value = 0
					subtract = gold
					min = 0
				}
			}
			scope:patrician_liege = {
				remove_short_term_treasury = scope:bankruptcy_relief
			}
			add_gold = scope:bankruptcy_relief
		}
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				scope:enactor ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}

			if = {
				limit = {
					has_trait = education_stewardship_1
				}
				add = {
					value = -5
					desc = gdp_decree_indulgent_wastrel_approval_desc
				}
			}
			if = {
				limit = {
					has_trait = profligate
				}
				add = {
					value = -5
					desc = gdp_decree_profligate_approval_desc
				}
			}
		}
	}

	ai_potential = {
		gdp_is_assembly_head_trigger = no
		treasury > major_treasury_value
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 10
		## Order in the city
		modifier = {
			capital_county = {
				county_control < county_control_baseline
			}
			add = 40
		}
		## Traits
		modifier = {
			has_trait = diligent
			factor = 1.4
		}
		modifier = {
			has_trait = paranoid
			factor = 2
		}
		modifier = {
			has_trait = zealous
			factor = 1.5
		}
		modifier = {
			OR = {
				has_trait = deceitful
				has_trait = lustful
			}
			factor = 0.5
		}
	}
}

# Petition the state for protection
gdp_petition_for_state_protection_decision = {
	title = gdp_petition_for_state_protection_decision
	desc = gdp_petition_for_state_protection_decision_desc
	selection_tooltip = gdp_petition_for_state_protection_decision_tooltip
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_african_culture_group_trigger = yes
					has_graphical_iranian_culture_group_trigger = yes
					has_graphical_mena_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_retire.dds"
	}
	picture = {
		trigger = { 
			culture = { 
				OR = { 
					has_graphical_india_culture_group_trigger = yes
					has_graphical_east_asia_or_southeast_asia_group_trigger = yes
				}
			} 
		}
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_assembly.dds"
	}
	sort_order = 20
	decision_group_type = republic_decree
	is_invisible = yes # We hide decrees, since they are shown in the Republic UI
	
	cooldown = { years = 6 }

	cost = {
		prestige = total_republic_decree_prestige_cost
		treasury_or_gold = {
			value = total_republic_decree_gold_cost
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 150
		duchy = 120
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	is_shown = {
		# You are a republic
		government_has_flag = government_is_republic
		has_gdp_dlc_trigger = yes	
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available_quick = {
			adult = yes
			at_war = no
			imprisoned = no
			incapable = no
		}
		# If assembly approval is required, we'll make sure that we are allowed to pass decrees
		gdp_assembly_can_pass_decrees_trigger = yes
	}

	effect = {
		add_character_modifier = {
			modifier = gdp_state_protection_modifier
			years = 5
		}
		gdp_enacted_decree_effect = yes
	}
	
	requires_approve = { gdp_assembly_approval_for_decrees_trigger = yes }
	
	ai_approval = {
		value = 0
		if = { # If voter has pledged support, then we only show their approval
			limit = {
				scope:enactor ?= {
					this != root
					is_target_in_variable_list = {
						name = decree_approvers
						target = root
					}
				}
			}
			add = {
				value = 100
				desc = decree_pledged_support_desc
			}
		}
		else = {
			add = republic_caucus_room_approval_value
			add = {
				value = ai_decree_approval_opinion_value
				multiply = 0.25
				desc = DECREE_OPINION_DESC
			}

			# House relation
			add = {
				value = ai_decree_approval_house_relation_value
				multiply = 0.5
				desc = DECREE_HOUSE_RELATION_DESC
			}

			if = {
				limit = {
					scope:enactor ?= {
						any_targeting_scheme = {
							count >= 2
							hostile_scheme_trigger = yes
						}
					}
				}
				add = {
					value = 7
					desc = gdp_multiple_hostile_schemes_approval_desc
				}
			}
			if = {
				limit = {
					scope:enactor ?= {
						any_targeting_scheme = {
							scheme_type = murder
							is_scheme_exposed = yes
						}
					}
				}
				add = {
					value = 10
					desc = gdp_known_murder_scheme_approval_desc
				}
			}
			if = {
				limit = { has_trait = brave }
				value = {
					value = 0.7
				}
			}
			if = {
				limit = { has_trait = paranoid }
				value = {
					value = 0.7
				}
			}
			if = {
				limit = { has_trait = callous }
				value = {
					value = 0.5
				}
			}
			if = {
				limit = { has_trait = craven }
				value = {
					value = 1.5
				}
			}
			if = {
				limit = { has_trait = cynical }
				value = {
					value = 0.9
				}
			}
		}
	}

	ai_potential = {
		treasury > major_treasury_value
		prestige > major_prestige_value
	}

	ai_will_do = {
		base = 10
		## Order in the city
		modifier = {
			capital_county = {
				county_control < county_control_baseline
			}
			add = 40
		}
		## Traits
		modifier = {
			has_trait = diligent
			factor = 1.4
		}
		modifier = {
			has_trait = paranoid
			factor = 2
		}
		modifier = {
			has_trait = zealous
			factor = 1.5
		}
		modifier = {
			OR = {
				has_trait = deceitful
				has_trait = lustful
			}
			factor = 0.5
		}
	}
}

