# Triggered modifiers are here.
# these are checked for each countries once/month and then applied.
#
# Effects are fully scriptable here.

###########################################
# Discovery of the East Indian trade route.
###########################################
east_indian_trade_route = {
	potential = {
		num_of_ports = 1
		NOT = {
			capital_scope = {
				continent = asia
			}
		}
		NOT = {
			capital_scope = {
				continent = oceania
			}
		}
		
	}

	trigger = {
		has_discovered = 1460 # Cape of Good Hope
		num_of_ports = 4
		has_idea = quest_for_the_new_world
		OR = {
			1361 = { has_merchant = ROOT } #Straits of Johor
			1343 = { has_merchant = ROOT } #Ganges Delta
			504 = { has_merchant = ROOT } #Sind
			1340 = { has_merchant = ROOT } #Comorin Cape
		}
	}

	trade_efficiency = 0.05	
}

#########################################################
# Coptic control of Alexandria.
#########################################################
#coptic_alexandria = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 358	# Alexandria
#		religion = coptic
#	}
#
#	trigger = {
#		owns = 358 # Alexandria
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
#
#########################################################
# Theravada control of the temple of the Sacred Tooth.
#########################################################
#theravada_kotte = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 2099	# Kandy
#		religion = buddhism #Theravada
#	}
#
#	trigger = {
#		owns = 2099 # Kandy
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Vajrayana control of Lhasa.
######################################
#vajrayana_lhasa = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 677	# Lhasa
#		religion = vajrayana
#	}
#
#	trigger = {
#		owns = 677 # Lhasa
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Mahayana control of Luoyang.
######################################
#mahayana_louyang = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 1836	# Luoyang
#		religion = mahayana
#	}
#
#	trigger = {
#		owns = 1836 # Luoyang
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Buddhist control of Bodh Gaya.
######################################
#buddhist_bodh_gaya = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 558	# Patna (Bodh Gaya)
#		OR = {
#			religion = buddhism
#			religion = vajrayana
#			religion = mahayana
#		}
#	}
#
#	trigger = {
#		owns = 558 # Patna (Bodh Gaya)
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Hindu control of Varanasi.
######################################
#hindu_varanasi = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 2095	# Varanasi
#		religion = hinduism
#	}
#
#	trigger = {
#		owns = 2095 # Varanasi
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}

######################################
# Inti control of Pachacamac.
######################################
#inti_lima = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 809 # Lima
#		religion = inti
#	}
#
#	trigger = {
#		owns = 809 # Lima
#		is_religion_reformed = yes
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Nahuatl control of Cholula.
######################################
#nahuatl_cholula = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 2644	# Cholula
#		religion = nahuatl
#	}
#
#	trigger = {
#		owns = 2644 # Cholula
#		is_religion_reformed = yes
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Mayan control of Chichen Itza.
######################################
#mayan_chichen_itza = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 846	# Chicen Itza
#		religion = mesoamerican_religion
#	}
#
#	trigger = {
#		owns = 846  # Chicen Itza
#		is_religion_reformed = yes
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Sikh control of Amritsar.
######################################
#sikh_amritsar = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 2075	# Amritsar
#		religion = sikhism
#	}
#
#	trigger = {
#		owns = 2075 # Amritsar
#		2075 = { religion = sikhism }
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Christian control of Mecca.
######################################
#christian_mecca = {
#	potential = {
#		normal_or_historical_nations = yes
#		has_discovered = 385	# Mecca
#		religion_group = christian
#	}
#
#	trigger = {
#		owns = 385 # Mecca
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}
#
######################################
# Custodian of the Two Holy Mosques
######################################
custodian_of_the_two_holy_mosques = {
	potential = {
		normal_or_historical_nations = yes
		has_discovered = 385	# Mecca
		has_discovered = 384	# Medina
		religion_group = muslim
	}

	trigger = {
		is_free_or_tributary_trigger = yes
		owns_or_vassal_of = 385
		owns_or_vassal_of = 384
	}

	legitimacy = 0.5
	missionaries = 1
}
###########################################
# Jerusalem held by Abrahamic Faiths
###########################################
#jerusalem_held = {
#	potential = {
#		normal_or_historical_nations = yes
#		OR = {
#			religion_group = christian
#			religion_group = muslim
#			religion = jewish
#		}
#		has_discovered = 379	# Judea
#	}
#
#	trigger = {
#		owns = 379 # Judea
#	}
#
#	prestige = 0.5
#	missionaries = 1
#}

######################################
# Catholic control of Rome.
######################################

papal_subjugation = {
	potential = {
		normal_or_historical_nations = yes
		has_discovered = 118	# Roma
		religion = catholic
		NOT = { tag = PAP }
	}

	trigger = {	
		overlord_of = PAP
		NOT = { tag = ITA }
		NOT = { tag = HLR }
		if = {
			limit = {
				is_emperor = yes
				has_dlc = "Emperor"
			}
			OR = {
				PAP = {
					NOT = { is_part_of_hre = yes }	#Needs to be written like that for localization purpose
				}
				NOT = { hre_reform_passed = emperor_privilegia_de_non_appelando }
			}
		}
		else_if = {
			limit = {
				is_emperor = yes
				NOT = { has_dlc = "Emperor" }
			}
			OR = {
				PAP = {
					NOT = { is_part_of_hre = yes }	#Needs to be written like that for localization purpose
				}
				NOT = { hre_reform_passed = privilegia_de_non_appelando }
			}
		}
		custom_trigger_tooltip = {
			tooltip = no_dip_malus_reward_tt
			NOT = { has_country_flag = general_flag_Rome_flag }			
		}
	}

	diplomatic_reputation = -2
	#icon = 9
}


rapid_collapse_of_society = {
	potential = {
		normal_or_historical_nations = yes
		capital_scope = {
			OR = {
				continent = north_america
				continent = south_america
				continent = new_world
			}
		}
		
	}
	trigger = {
		NOT = { has_institution = feudalism }
		OR = {
			technology_group = north_american
			technology_group = mesoamerican
			technology_group = south_american
			technology_group = andean
		}
		custom_trigger_tooltip = {
			tooltip = rapid_collapse_of_society_tooltip
			has_country_flag = european_diseases_struck
			NOT = {
				had_country_flag = {
					flag = european_diseases_struck
					days = 9125
				}
			}
		}
	}
	
	all_power_cost = 0.33
	discipline = -0.1
	land_morale = -0.2
	
}

######################################
# Italian - Submission to Emperor
######################################
submission_to_emperor = {
	potential = {
		# AI will avoid joining HRE when this modifier is potential:

		has_global_flag = italians_leave_hre
		NOT = { has_country_flag = reined_in_for_shadow_kingdom }
		is_emperor = no
		NOT = { is_year = 1550 }
		culture_group = latin
		OR = {
			is_subject = no
			overlord = { is_emperor = no }
		}
	}

	trigger = {
		is_part_of_hre = yes
		NOT = { tag = ITA }
		NOT = { emperor = { alliance_with = ROOT } }
		NOT = { is_year = 1550 } # Duplicating so it shows in tooltip
	}

	global_unrest = 3
	stability_cost_modifier = 0.1
	prestige = -1
}



######################################
# Counter Revolution
######################################
counter_revolution = {
	potential = {
		revolution_target_exists = yes
		is_revolutionary = no
		any_country = {
			is_revolution_target = yes
			OR = {
				capital_scope = {
					continent = ROOT
				}
				is_neighbor_of = ROOT
			}
		}
	}

	trigger = {
		revolution_target_exists = yes
		is_revolutionary = no
		is_free_or_tributary_trigger = yes
		NOT = {
			revolution_target = {
				war_with = ROOT
			}
			revolution_target = {
				truce_with = ROOT
			} 
		}
		government = monarchy
	}

	prestige = -5
	stability_cost_modifier = 0.3
	global_unrest = 5
}



######################################
# Reaction
######################################
reaction = {
	potential = {
		revolution_target_exists = yes
		is_revolutionary = no
		any_country = {
			is_revolution_target = yes
			capital_scope = {
				continent = ROOT
			}
		}
	}

	trigger = {
		revolution_target_exists = yes
		is_revolutionary = no
		is_free_or_tributary_trigger = yes
		government = monarchy
		revolution_target = {
			war_with = ROOT
		}  

	}

	prestige = 10
	stability_cost_modifier = -0.1
	global_unrest = -10
}

######################################
# Crusader
######################################
crusader = {
	potential = {
		religion = catholic
		crusade_target = {
			exists = yes
		}
		
	}

	trigger = {
		
		crusade_target = {
			war_with = ROOT
			any_province = {
				controlled_by = root
			}
		}  
		land_maintenance = 1.0
	}

	global_manpower_modifier = 0.3
	global_tax_modifier = 0.1
	land_morale = 0.10
	prestige = 1
	papal_influence = 1
	devotion = 0.25
	#icon = 9
}

######################################
# Excommunication
######################################
excommunication = {
	potential = {
		religion = catholic	
	}

	trigger = {
		is_excommunicated = yes
		
	}

	prestige = -2
	tolerance_own = -3
	devotion = -5
	papal_influence = -10
	#icon = 10
}

##################################################
# The Pentarchy
##################################################
pentarchy_mod = {
	potential = {
		normal_or_historical_nations = yes
		religion = orthodox
		OR = {
			has_discovered = 118 	# Rome
			has_discovered = 151 	# Constantinople
			has_discovered = 2313 	# Antioch
			has_discovered = 379 	# Jerusalem
			has_discovered = 358 	# Alexandria
		}
	}

	trigger = {
		owns = 118 	# Rome
		owns = 151 	# Constantinople
		owns = 2313 # Antioch
		owns = 379 	# Jerusalem
		owns = 358 	# Alexandria
		118 = { religion = orthodox }
		151 = { religion = orthodox }
		2313 = { religion = orthodox }
		379 = { religion = orthodox }
		358 = { religion = orthodox }
	}
	
	prestige = 0.5
	missionaries = 1
}

##################################################
# China modifiers
##################################################
the_mandate_of_heaven = {
	potential = {
		has_reform = celestial_empire
		NOT = { has_dlc = "Mandate of Heaven" }
	}
	
	trigger = {	
		stability = 0
		legitimacy = 60
		num_of_cities = 20
	}

	stability_cost_modifier = -0.10
	global_unrest = -5
}

the_mandate_of_heaven_lost = {
	potential = {
		has_reform = celestial_empire
		NOT = { has_dlc = "Mandate of Heaven" }
	}

	trigger = {
		OR = {
			NOT = { stability = 0 }
			NOT = { legitimacy = 60 }
			NOT = { num_of_cities = 20 }	
		}
	}

	discipline = -0.1
	stability_cost_modifier = 0.5
	global_unrest = 10
}

ai_wants_chinese_capitals = {
	potential = {
		ai = yes
		OR = {
			owns = 1816
			owns = 1821
			owns = 667
			owns = 1836		#MMETR added Luoyang and Chang'an
			owns = 700
		}
		has_dlc = "Mandate of Heaven"
		capital_scope = {
			superregion = china_superregion
		}
	}
	trigger = {
		owns = 1816
		owns = 1821
		owns = 667
		owns = 1836		#MMETR added Luoyang and Chang'an
		owns = 700
	}

	ai_weight = {
		factor = 100 # Makes AI try to conquer the cities
	}
}

lost_control_of_beijing = {
	potential = {
		has_reform = celestial_empire
		has_dlc = "Mandate of Heaven"
	}

	trigger = {
		OR = {
			NOT = { owns = 1816 }
			NOT = { controls = 1816 }
		}
	}

	ai_weight = {
		factor = -1000 # Do what you can to avoid this modifier
	}

	imperial_mandate = -0.05
}

lost_control_of_nanjing = {
	potential = {
		has_reform = celestial_empire
		has_dlc = "Mandate of Heaven"
	}

	trigger = {
		OR = {
			NOT = { owns = 1821 }
			NOT = { controls = 1821 }
		}
	}

	ai_weight = {
		factor = -1000 # Do what you can to avoid this modifier
	}

	imperial_mandate = -0.05
}

lost_control_of_canton = {
	potential = {
		has_reform = celestial_empire
		has_dlc = "Mandate of Heaven"
	}

	trigger = {
		OR = {
			NOT = { owns = 667 }
			NOT = { controls = 667 }
		}
	}

	ai_weight = {
		factor = -1000 # Do what you can to avoid this modifier
	}

	imperial_mandate = -0.05
}

waging_war_for_china = {
	potential = {
		has_reform = celestial_empire
		has_dlc = "Mandate of Heaven"
	}

	trigger = {
		is_in_war = {
			attacker_leader = root
			casus_belli = cb_chinese_unification
		}
	}
	
	imperial_mandate = 0.05
}

##################################################
# HRE modifiers
##################################################
hre_dominant_catholic = {
	potential = {
		capital_scope = {
			continent = europe
		}
		OR = {
			religion = catholic
			religion = protestant
			religion = reformed
		}
	}

	trigger = {
		religion = catholic
		hre_religion = catholic
		hre_religion_locked = yes
	}
	
	legitimacy = 0.25
	tolerance_own = 1
	global_missionary_strength = 0.01
	imperial_authority = 0.25
}

hre_dominant_protestant = {
	potential = {
		capital_scope = {
			continent = europe
		}
		OR = {
			religion = catholic
			religion = protestant
			religion = reformed
		}
	}

	trigger = {
		religion = protestant
		hre_religion = protestant
		hre_religion_locked = yes
	}
	
	legitimacy = 0.25
	tolerance_own = 1
	global_missionary_strength = 0.01
	imperial_authority = 0.25
}

hre_dominant_reformed = {
	potential = {
		capital_scope = {
			continent = europe
		}
		OR = {
			religion = catholic
			religion = protestant
			religion = reformed
		}
	}

	trigger = {
		religion = reformed
		hre_religion = reformed
		hre_religion_locked = yes
	}
	
	legitimacy = 0.25
	tolerance_own = 1
	global_missionary_strength = 0.01
	imperial_authority = 0.25
}

hre_dominant_hussite = {
	potential = {
		capital_scope = {
			continent = europe
		}
		OR = {
			religion = catholic
			religion = protestant
			religion = reformed
			religion = hussite
		}
	}

	trigger = {
		religion = hussite
		hre_religion = hussite
		hre_religion_locked = yes
	}
	
	legitimacy = 0.25
	tolerance_own = 1
	global_missionary_strength = 0.01
	imperial_authority = 0.25
}

######################################
# Robot parts
######################################

synthetic_remnants = {
	potential = {
		has_global_flag = synthetics_defeated
	}
	trigger = {
		has_global_flag = synthetics_defeated
	}
	technology_cost = -0.25
}

######################################
# The Golden Age of Piracy
######################################

golden_age_of_piracy = {
	potential = {
		has_global_flag = golden_age_of_piracy
		NOT = { # lasts 50 years
			had_global_flag = { flag = golden_age_of_piracy days = 18250 }
		}
		1516 = { has_discovered = ROOT }
	}
	trigger = {
		1516 = {
			privateer_power = { country = ROOT share = 1 }
		}
	}
	privateer_efficiency = 0.2
}

######################################
# The Great Peasants' War
######################################

great_peasants_war_triggered_modifier = {
	potential = {
		has_global_flag = great_peasants_war_flag
		capital_scope = {
			continent = europe
		}
	}
	trigger = {
		is_part_of_hre = yes
		NOT = { has_government_attribute = is_peasants_republic }
	}
	global_unrest = 6
}

great_peasants_war_concessions_triggered_modifier = {
	potential = {
		OR = {
			has_global_flag = gpw_peasants_win_major
			has_global_flag = gpw_peasants_win_minor
		}
		capital_scope = {
			continent = europe
		}
	}
	trigger = {
		is_part_of_hre = yes
		NOT = { has_government_attribute = is_peasants_republic }
	}
	global_tax_modifier = -0.05
}

######################################
# Pope is in the empire
######################################

pope_in_hre_triggered_modifier = {
	potential = {
		PAP = { is_part_of_hre = yes }
		religion = catholic
	}
	trigger = {
		PAP = { is_part_of_hre = yes }
		religion = catholic
		NOT = { is_part_of_hre = yes }
	}
	prestige = -0.5
}

######################################
# The Italian Wars
######################################

italian_wars_triggered_modifier = {
	potential = {
		has_global_flag = italian_wars_global_flag
		capital_scope = {
			continent = europe
		}
		religion_group = christian
	}
	trigger = {
		OR = {
			AND = {
				capital_scope = { region = italy_region }
				any_country = {
					war_with = ROOT
					religion_group = christian
					capital_scope = { continent = europe }
					total_development = 150
				}
			}
			AND = {
				NOT = { capital_scope = { region = italy_region } }
				total_development = 150
				any_country = {
					war_with = ROOT
					capital_scope = { region = italy_region }
				}
			}
		}
	}
	mercenary_cost = -0.10
	mercenary_discipline = 0.05
}

######################################
# Defense of the Empire
######################################

defense_of_the_empire_modifier = {
	potential = {
		has_dlc = "Emperor"
		OR = {
			is_emperor = yes
			is_elector = yes
		}
		hre_reform_passed = emperor_reichskrieg
	}
	trigger = {
		any_country = {
			war_with = ROOT
			NOT = { is_part_of_hre = yes }
		}
	}
	war_taxes_cost_modifier = -1.0
}

######################################
# Judaism Defensive Aspect
######################################

judaism_yom_kippur_aspect_war_modifier = {
	potential = {
		religion = jewish
		has_church_aspect = judaism_yom_kippur_aspect
	}
	trigger = {
		is_at_war = yes
	}
	manpower_recovery_speed = 0.20
	church_power_modifier = 0.25
}

judaism_yom_kippur_aspect_defensive_war_modifier = {
	potential = {
		religion = jewish
		has_church_aspect = judaism_yom_kippur_aspect
	}
	trigger = {
		is_at_war = yes
		is_in_war = {
			defenders = ROOT
		}
	}
	manpower_recovery_speed = 0.20
	church_power_modifier = 0.25
}

######################################
# Government Reform Specific
######################################

ahmudan_system_attacker = {
	potential = {
		has_government_attribute = ahmudan_system
	}

	trigger = {
		is_at_war = yes
	}
	global_regiment_cost = -0.1
	manpower_recovery_speed = 0.2
}

ahmudan_system_defender = {
	potential = {
		has_government_attribute = ahmudan_system
	}

	trigger = {
		is_in_war = {
			defenders = ROOT
		}
	}
	land_morale = 0.075
	defensiveness = 0.15
	manpower_recovery_speed = 0.1
}

TIM_diwan_adm = {
	potential = {
		has_reform = timurid_diwan_reform
	}

	trigger = {
		national_focus = adm
	}
	yearly_corruption = -0.15
}

TIM_diwan_dip = {
	potential = {
		has_reform = timurid_diwan_reform
	}

	trigger = {
		national_focus = dip
	}
	global_unrest = -1
}

TIM_diwan_mil = {
	potential = {
		has_reform = timurid_diwan_reform
	}

	trigger = {
		national_focus = mil
	}
	land_maintenance_modifier = -0.1
}