decisions = {
	
	enact_amalfi_laws = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 60
		
		potential = {
			is_playable = yes
			NOT = { has_global_flag = VIET_amalfi_laws_enacted }
			NOT = { has_character_flag = VIET_amalfi_laws_enacting_happening }
			OR = {
				has_landed_title = c_amalfi
				has_landed_title = d_amalfi
				has_landed_title = k_amalfi
			}
			is_tribal = no
			is_nomadic = no
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 100
			OR = {
				935 = {
					TECH_TRADE_PRACTICES = 2	
					TECH_LEGALISM = 2	
				}
				year = 900
				has_global_flag = VIET_amalfi_laws_cheat
			}
			OR = {
				is_merchant_republic = yes
				higher_real_tier_than = COUNT
			}
		}
		effect = {
			wealth = -100
			hidden_tooltip = {
				set_character_flag = VIET_amalfi_laws_enacting_happening
				set_global_flag = VIET_amalfi_laws_enacted
				long_character_event = { id = amalfi.10 }
			}
		}
		ai_will_do = {
			factor = 1			
			modifier = {
				factor = 0
				NOT = {
					year = 900
				}
			}			
			modifier = {
				factor = 0.05
				NOT = {
					year = 1000
				}
			}				
			modifier = {
				factor = 0.2
				NOR = {
					is_patrician = yes
					is_merchant_republic = yes
				}
			}					
			modifier = {
				factor = 0.2
				NOR = {
					culture_group = latin
					culture_group = byzantine
				}
			}			
		}
	}		
	
	reform_amalfi_laws = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 60
		
		potential = {
			is_playable = yes
			has_global_flag = VIET_amalfi_laws_enacted
			OR = {
				has_landed_title = c_amalfi
				has_landed_title = d_amalfi
				has_landed_title = k_amalfi
			}
			is_tribal = no
			is_nomadic = no
			935 = {
				NOR = {
					has_province_modifier = VIET_amalfian_laws_enacted
					has_province_modifier = VIET_amalfian_laws_reformed
				}
			}
			NOT = { has_character_modifier = VIET_amalfi_law_creator }
			NOT = { has_character_modifier = VIET_amalfi_law_reformer }
			NOT = { has_character_flag = VIET_amalfi_laws_reform_happening }
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 50
			OR = {
				is_merchant_republic = yes
				higher_real_tier_than = COUNT
			}
		}
		effect = {
			wealth = -50
			hidden_tooltip = {
				set_character_flag = VIET_amalfi_laws_reform_happening
				long_character_event = { id = amalfi.12 }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.2
				NOR = {
					is_patrician = yes
					is_merchant_republic = yes
				}
			}					
			modifier = {
				factor = 0.2
				NOR = {
					culture_group = latin
					culture_group = byzantine
				}
			}			
		}
	}	

	restore_temple_of_the_sirens = {
		only_playable = yes
		ai_check_interval = 100
		potential = {
			is_playable = yes
			is_adult = yes
			prisoner = no
			OR = {
				religion = hellenic_pagan
				religion = hellenic_pagan_reformed
				religion = titan_pagan		# ACR compatibility
				religion = promethean_pagan	# ACR compatibility
				has_religion_feature = religion_cosmopolitan
				has_religion_feature = religion_syncretic
				has_religion_feature = religion_matriarchal
				has_religion_feature = religion_seafaring
			}
			has_landed_title = c_amalfi
			NOT = { has_global_flag = VIET_siren_temple_start_rebuilding }
			NOT = { has_global_flag = VIET_siren_temple_restored }
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 100
		}
		effect = {
			wealth = -100
			#set_global_flag = VIET_siren_temple_restored
			hidden_tooltip = {
				long_character_event = { id = amalfi.21 }
				935 = {
					province_event = { id =  amalfi.22 days = 730 random = 90 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.01
				NOT = {
					wealth = 100
				}
			}
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
	}	

	make_offerings_to_sirens = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 24
		
		potential = {
			is_playable = yes
			has_global_flag = VIET_siren_temple_restored
			OR = {
				#any_demesne_province = {
				#	has_province_modifier = VIET_temple_of_sirens
				#}
				#any_realm_province = {
				#	has_province_modifier = VIET_temple_of_sirens
				#}
				has_landed_title = c_amalfi
				any_liege = {
					has_landed_title = c_amalfi
				}
			}
			religion_group = pagan_group
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			custom_tooltip = { 
				text = VIET_recent_siren_temple_visit 
				hidden_tooltip = {
					NOT = { has_character_modifier = VIET_siren_temple_timer }
				}
			}
			wealth = 20
		}
		effect = {
			#wealth = -25
			hidden_tooltip = {
				set_variable = { which = amalfi_siren_value value = 0 }
				character_event = { id = amalfi.24 }
			}
		}
		ai_will_do = {
			factor = 0.3
			modifier = {
				trait = zealous
				factor = 2
			}
			modifier = {
				NOR = {
					religion = hellenic_pagan
					religion = hellenic_pagan_reformed
					religion = titan_pagan		# ACR compatibility
					religion = promethean_pagan	# ACR compatibility
				}
				factor = 0.5
			}
		}
	}

	bambagina_paper_status = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 100
		
		potential = {
			is_playable = yes
			has_global_flag = VIET_bambagina_paper_invented
			#OR = {
			#	is_merchant_republic = yes
			#	higher_real_tier_than = DUKE
			#}
			#OR = {
			#	has_landed_title = c_amalfi
			#	any_realm_character = {
			#		has_landed_title = c_amalfi
			#	}
			#}
			has_landed_title = c_amalfi
			#independent = yes
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 50
			prestige = 50
			NOT = { has_character_flag = VIET_changing_amalfi_paper_law_currently }
			custom_tooltip = { text = VIET_recent_bambagina_paper_change }
			hidden_tooltip = {
				NOT = {
					935 = {
						has_province_modifier = VIET_bambagina_paper_timer 
					}
				}
			}
		}
		effect = {
			#wealth = -25
			#prestige = -50
			set_character_flag = VIET_changing_amalfi_paper_law_currently
			hidden_tooltip = {
				long_character_event = { id = amalfi.31 }
			}
		}
		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 0.1
				935 = {
					has_province_modifier = VIET_bambagina_paper_tolerate
				}
			}
			modifier = {
				factor = 2
				935 = {
					has_province_modifier = VIET_bambagina_paper_support
				}
			}
			modifier = {
				factor = 2
				935 = {
					has_province_modifier = VIET_bambagina_paper_ban
				}
			}
			modifier = {
				factor = 0.01
				trait = content
			}
			modifier = {
				factor = 0.01
				trait = slothful
			}
			modifier = {
				factor = 3
				trait = ambitious
			}
		}
	}	

	found_amalfion = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 100
		
		potential = {
			#is_playable = yes
			is_patrician = yes
			is_adult = yes
			OR = {
				has_landed_title = c_amalfi
				has_landed_title = d_amalfi
				has_landed_title = k_amalfi	
			}
			NOT = { has_global_flag = VIET_amalfi_amalfion_founded }
			NOT = { has_global_flag = schism_mended }
			NOT = { has_character_modifier = VIET_amalfi_established_amalfion }
			religion_group = christian
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 100
			OR = {
				is_title_active = e_byzantium
				is_title_active = e_roman_empire
				491 = {
					owner = {
						religion_group = christian
					}
				}
			}
			491 = {
				religion_group = christian
			}
			#e_byzantium = {
			#	owner = {
			#		realm_size = 50
			#		OR = {
			#			has_landed_title = c_byzantion
			#			any_vassal = {
			#				has_landed_title = c_byzantion
			#			}
			#		}
			#		NOT = {
			#			religion = ROOT
			#		}
			#		religion_group = ROOT
			#	}
			#}
			#d_thrace = {
			#	de_jure_liege = k_thrace
			#}
			OR = {
				935 = {
					TECH_RELIGIOUS_CUSTOMS = 2	
					TECH_CULTURE_FLEX = 2	
				}
				year = 900
				has_global_flag = VIET_amalfi_laws_cheat
			}
		}
		effect = {
			wealth = -100
			prestige = 100
			piety = 200
			hidden_tooltip = {
				long_character_event = { id = amalfi.50 }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
				trait = content
			}
			modifier = {
				factor = 0.1
				trait = slothful
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = diligent
			}
			modifier = {
				factor = 0
				trait = cynical
			}
			modifier = {
				factor = 0
				trait = zealous
			}
			modifier = {
				factor = 0
				NOT = { year = 800 }
			}
			modifier = {
				factor = 0.3
				NOT = { year = 900 }
			}
			modifier = {
				factor = 0.7
				NOT = { year = 950 }
			}
			#modifier = { #for testing purposes
			#	factor = 1000
			#	year = 930
			#}
		}
	}	

	choose_amalfi_business_focus = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 12
		
		potential = {
			#is_playable = yes
			is_patrician = yes
			is_adult = yes
			OR = {
				has_landed_title = c_amalfi
				has_landed_title = d_amalfi
				has_landed_title = k_amalfi	
				any_liege = {
					OR = {
						has_landed_title = c_amalfi
						has_landed_title = d_amalfi
						has_landed_title = k_amalfi
					}
				}
			}
		}
		allow = {
			#war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			wealth = 25
			prestige = 25
			NOT = { has_character_flag = VIET_changing_amalfi_focus_currently }
			custom_tooltip = { 
				text = VIET_no_current_amalfi_focus 
				hidden_tooltip = {
					NOR = {
						has_character_modifier = VIET_amalfi_chestnut_focus
						has_character_modifier = VIET_amalfi_ceramics_focus
						has_character_modifier = VIET_amalfi_silk_focus
						has_character_modifier = VIET_amalfi_fish_focus
						has_character_modifier = VIET_amalfi_coral_focus
						has_character_modifier = VIET_amalfi_lemon_focus
					}
				}
			}
		}
		effect = {
			wealth = -25
			prestige = -25
			set_character_flag = VIET_changing_amalfi_focus_currently
			hidden_tooltip = {
				character_event = { id = amalfi.3 }
			}
		}
		ai_will_do = {
			factor = 0.5
			modifier = {
				factor = 0.1
				trait = content
			}
			modifier = {
				factor = 0.1
				trait = slothful
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = diligent
			}
			modifier = {
				factor = 2
				trait = greedy
			}
		}
	}	
}