
namespace = Plus

#reserved: Plus.700 to Plus.729

#######################################
# JEWISH EVENTS
#######################################

# Jewish community grows
character_event = {
	id = Plus.700 #formerly 1000182984
	desc = "EVTDESC_Plus_700"
	picture = GFX_evt_market
	
	only_rulers = yes
	war = no

	trigger = {
		any_demesne_province = {
			has_building = ct_jewish_community_1
			OR = {
				ROOT = { ai = yes }
				NOT = { has_building = ct_jewish_community_3 }
			}
			NOT = { has_province_modifier = brm_revolt }
			OR = {
				AND = {
					OR = {
						has_province_modifier = province_prosperity_1
						has_province_modifier = province_prosperity_2
					}
					NOT = { has_dlc = "Reapers" }
				}
				has_dlc = "Reapers"
			}
		}
		OR = {
			is_patrician = yes
			NOT = { tier = baron }
			NOT = { 
				liege = { 
					has_character_flag = pogrom 
					has_character_modifier = expelled_jews_timer
				}
			}
		}
		NOR = { 
			has_character_flag = pogrom 
			has_character_modifier = expelled_jews_timer
		}
	}

	mean_time_to_happen = {
		months = 1200
		modifier = {
			factor = 2
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = zealous
		}
		modifier = {
			factor = 1.5
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = cruel
		}
		modifier = {
			factor = 1.5
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = arbitrary
		}
		modifier = {
			factor = 0.75
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = just
		}
		modifier = {
			factor = 0.75
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = charitable
		}
		modifier = {
			factor = 2
			tier = baron is_patrician = no
			liege = { trait = zealous }
		}
		modifier = {
			factor = 1.5
			tier = baron is_patrician = no
			liege = { trait = cruel }
		}
		modifier = {
			factor = 1.5
			tier = baron is_patrician = no
			liege = { trait = arbitrary }
		}
		modifier = {
			factor = 0.75
			tier = baron is_patrician = no
			liege = { trait = just }
		}
		modifier = {
			factor = 0.75
			tier = baron is_patrician = no
			liege = { trait = charitable }
		}
		modifier = {
			factor = 1.5
			any_demesne_province = {
				has_building = ct_jewish_community_2
			}
		}
		modifier = {
			factor = 1.5
			any_demesne_province = {
				has_building = ct_jewish_community_3
			}
		}
		modifier = {
			factor = 0.66
			OR = {
				AND = {
					any_demesne_province = {
						has_building = ct_jewish_community_1
						has_province_modifier = province_prosperity_2
					}
					NOT = { has_dlc = "Reapers" }
				}
				AND = {
					any_demesne_province = {
						has_building = ct_jewish_community_1
					}
					has_dlc = "Reapers"
				}
			}
		}
	}

	option = {
		name = "EXCELLENT"
		random_demesne_title = {
			limit = {
				tier = baron
				has_building = ct_jewish_community_1
				OR = {
					ROOT = { ai = yes }
					NOT = { has_building = ct_jewish_community_3 }
				}
				location = {
					NOT = { has_province_modifier = brm_revolt }
					OR = {
						has_province_modifier = province_prosperity_1
						has_province_modifier = province_prosperity_2
						has_dlc = "Reapers"
					}
				}
			}
			hidden_tooltip = {
				if = {
					limit = { has_building = ct_jewish_community_3 }
					hidden_tooltip = {
						333 = { change_variable = { which = "jewish_refugees" value = 1 } }
					}
				}
			}
			if = {
				limit = {
					NOT = { has_building = ct_jewish_community_3 }
					has_building = ct_jewish_community_2
				}
				add_building = ct_jewish_community_3
				ROOT = {
					if = {
						limit = {
							tier = baron
							NOT = { demesne_size = 2 }
						}
						liege = {
							letter_event = { id = Plus.702 days = 3 }
						}
					}
				}
			}
			if = {
				limit = {
					NOT = { has_building = ct_jewish_community_3 }
					NOT = { has_building = ct_jewish_community_2 }
					has_building = ct_jewish_community_1
				}
				add_building = ct_jewish_community_2
				ROOT = {
					if = {
						limit = {
							tier = baron
							NOT = { demesne_size = 2 }
						}
						liege = {
							letter_event = { id = Plus.701 days = 3 }
						}
					}
				}
			}
		}
	}
}

# Liege informed that jewish community has grown
letter_event = {
	id = Plus.701
	desc = "EVTDESC_Plus_701"

	is_triggered_only = yes

	ai = no

	option = {
		name = "EXCELLENT"
		FROM = {
			primary_title = {
				tooltip = { add_building = ct_jewish_community_2 }
			}
		}
	}
}

# Liege informed that jewish community has grown
letter_event = {
	id = Plus.702
	desc = "EVTDESC_Plus_701"

	is_triggered_only = yes

	ai = no

	option = {
		name = "EXCELLENT"
		FROM = {
			primary_title = {
				tooltip = { add_building = ct_jewish_community_3 }
			}
		}
	}
}

# Jewish courtier
character_event = {
	id = Plus.703 #formerly 1000182987
	picture = GFX_evt_emissary
	desc = "EVTDESC_Plus_703"
	
	only_rulers = yes
	war = no

	trigger = {
		any_demesne_province = {
			has_building = ct_jewish_community_1
		}
		OR = {
			NOT = { tier = baron }
			NOT = { 
				liege = { 					
					has_character_flag = pogrom 
					has_character_modifier = expelled_jews_timer 
				} 
			}
		}
		NOR = { 					
			has_character_flag = pogrom 
			has_character_modifier = expelled_jews_timer 
		}
	}

	mean_time_to_happen = {
		months = 1000
		modifier = {
			factor = 2
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = zealous
		}
		modifier = {
			factor = 1.5
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = cruel
		}
		modifier = {
			factor = 1.5
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = arbitrary
		}
		modifier = {
			factor = 0.75
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = just
		}
		modifier = {
			factor = 0.75
			OR = { higher_tier_than = baron is_patrician = yes }
			trait = charitable
		}
		modifier = {
			factor = 2
			tier = baron is_patrician = no
			liege = { trait = zealous }
		}
		modifier = {
			factor = 1.5
			tier = baron is_patrician = no
			liege = { trait = cruel }
		}
		modifier = {
			factor = 1.5
			tier = baron is_patrician = no
			liege = { trait = arbitrary }
		}
		modifier = {
			factor = 0.75
			tier = baron is_patrician = no
			liege = { trait = just }
		}
		modifier = {
			factor = 0.75
			tier = baron is_patrician = no
			liege = { trait = charitable }
		}
		modifier = {
			factor = 0.66
			any_demesne_province = {
				has_building = ct_jewish_community_2
			}
		}
		modifier = {
			factor = 0.66
			any_demesne_province = {
				has_building = ct_jewish_community_3
			}
		}
	}

	option = {
		name = "OK"
		if = {
			limit = {
				OR = {
					culture = levantine_arabic
					culture = bedouin_arabic
					culture = egyptian_arabic
					culture_group = altaic
					culture_group = iranian
					culture_group = east_african
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = mizrahim
				female = no
			}
			new_character = {
				set_character_flag = jewish_advisor
				random = {
					chance = 50
					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = mizrahim
						female = yes
					}
					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}
		if = {
			limit = {
				OR = {
					culture = andalusian_arabic
					culture = maghreb_arabic
					culture = sicilian_arabic
					culture_group = west_african
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = sephardi
				female = no
			}
			new_character = {
				set_character_flag = jewish_advisor
				random = {
					chance = 50
					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = sephardi
						female = yes
					}
					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}
		if = {
			limit = {
				NOR = {
					culture_group = arabic
					culture_group = altaic
					culture_group = iranian
					culture_group = east_african
					culture_group = west_african
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = ashkenazi
				female = no
			}
			new_character = {
				set_character_flag = jewish_advisor
				random = {
					chance = 50
					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = ashkenazi
						female = yes
					}
					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}
		hidden_tooltip = {
			if = {
				limit = { tier = baron }
				liege = {
					ROOT = {
						any_courtier = {
							limit = { has_character_flag = jewish_advisor }
							clr_character_flag = jewish_advisor
							banish = PREVPREV
						}
					}
				}
			}
			any_courtier = {
				limit = { has_character_flag = jewish_advisor }
				clr_character_flag = jewish_advisor
			}
		}
	}
}

# Jewish refugees wish to settle in your holding
character_event = {
	id = Plus.704 #formerly 1000182988
	desc = "EVTDESC_Plus_704"
	picture = GFX_evt_emissary
	
	only_rulers = yes
	war = no

	trigger = {
		OR = {
			higher_tier_than = baron
			is_patrician = yes
		}
		OR = {
			religion_group = christian
			religion_group = muslim
			religion_group = pagan_group
		}
		333 = { check_variable = { which = "jewish_refugees" value = 0.5 } }
		OR = {
			any_demesne_province = {
				has_building = ct_wall_1
				NOT = { has_building = ct_jewish_community_3 }
			}
			any_vassal = {
				tier = baron
				is_patrician = no
				any_demesne_province = {
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}
			}
		}
		NOT = {
			any_liege = {			
				has_character_flag = pogrom 
				has_character_modifier = expelled_jews_timer 
			}
		}
		NOR = {
			has_character_flag = jews_not_welcome
			has_character_flag = pogrom
			has_character_modifier = expelled_jews_timer
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 2
			liege = { trait = zealous }
		}
		modifier = {
			factor = 1.5
			liege = { trait = cruel }
		}
		modifier = {
			factor = 1.5
			liege = { trait = arbitrary }
		}
		modifier = {
			factor = 0.75
			liege = { trait = just }
		}
		modifier = {
			factor = 0.75
			liege = { trait = charitable }
		}
		modifier = {
			factor = 0.75
			religion_group = muslim
		}
		modifier = {
			factor = 1.5
			religion_group = pagan_group
		}
		modifier = {
			factor = 2.0
			OR = {
				religion = orthodox
				religion = chalcedonian
			}
		}
		modifier = {
			factor = 10.0
			OR = {
				culture_group = north_germanic
				culture_group = celtic
				culture_group = finno_ugric
				culture_group = west_african
			}
		}
		modifier = {
			factor = 5.0
			OR = {
				culture_group = byzantine
				culture_group = baltic
				culture_group = south_slavic
				culture_group = east_african
			}
		}
		modifier = {
			factor = 2.0
			OR = {
				culture_group = west_germanic
				culture_group = altaic
				culture_group = east_slavic
				culture_group = magyar
			}
		}
		modifier = {
			factor = 3.0
			tier = count
		}
		modifier = {
			factor = 2.0
			tier = duke
		}
		modifier = {
			factor = 0.75
			tier = emperor
		}
		modifier = {
			factor = 0.66
			OR = {
				any_demesne_province = {
					has_building = ct_jewish_community_1
				}
				any_vassal = {
					tier = baron
					is_patrician = no
					any_demesne_province = {
						has_building = ct_jewish_community_1
					}
				}
			}
		}
	}

	immediate = {
		hidden_tooltip = {
			333 = { change_variable = { which = "jewish_refugees" value = -1 } }
		}
	}

	option = {
		name = "EVTOPTA_Plus_704" #They are welcome
		ai_chance = {
			factor = 75
			modifier = {
				factor = 0.66
				religion_group = christian
			}
			modifier = {
				factor = 0.1
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 1.5
				trait = kind
			}
			modifier = {
				factor = 2.0
				trait = charitable
			}
		}
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
		if = {
			limit = {
				tier = baron
				any_demesne_title = {
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}
			}
			random_demesne_title = {
				limit = {
					tier = baron
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}
				if = {
					limit = {
						NOT = { has_building = ct_jewish_community_3 }
						has_building = ct_jewish_community_2
					}
					add_building = ct_jewish_community_3
				}
				if = {
					limit = {
						NOT = { has_building = ct_jewish_community_3 }
						NOT = { has_building = ct_jewish_community_2 }
						has_building = ct_jewish_community_1
					}
					add_building = ct_jewish_community_2
				}
				if = {
					limit = {
						NOT = { has_building = ct_jewish_community_3 }
						NOT = { has_building = ct_jewish_community_2 }
						NOT = { has_building = ct_jewish_community_1 }
					}
					add_building = ct_jewish_community_1
				}
			}
		}
		if = {
			limit = {
				tier = baron
				NOT = {
					any_demesne_title = {
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}
				}
			}
			random_vassal = {
				limit = {
					tier = baron
					is_patrician = no
					any_demesne_title = {
						tier = baron
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}
				}
				random_demesne_title = {
					limit = {
						tier = baron
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}
					if = {
						limit = {
							NOT = { has_building = ct_jewish_community_3 }
							has_building = ct_jewish_community_2
						}
						add_building = ct_jewish_community_3
					}
					if = {
						limit = {
							NOT = { has_building = ct_jewish_community_3 }
							NOT = { has_building = ct_jewish_community_2 }
							has_building = ct_jewish_community_1
						}
						add_building = ct_jewish_community_2
					}
					if = {
						limit = {
							NOT = { has_building = ct_jewish_community_3 }
							NOT = { has_building = ct_jewish_community_2 }
							NOT = { has_building = ct_jewish_community_1 }
						}
						add_building = ct_jewish_community_1
					}
				}
			}
		}
		any_vassal = {
			limit = {
				NOT = { trait = charitable }
				NOT = { trait = just }
				NOT = { trait = kind }
				NOT = { trait = zealous }
				is_republic = no
			}
			opinion = {
				who = ROOT
				modifier = opinion_settled_jews
				years = 10
			}
		}
		any_vassal = {
			limit = {
				NOT = { trait = charitable }
				NOT = { trait = just }
				NOT = { trait = kind }
				trait = zealous
				is_republic = no
			}
			opinion = {
				who = ROOT
				modifier = opinion_settled_jews
				years = 10
				multiplier = 2
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_tradition } }
			custom_tooltip = { text = TRADITIONFACTIONMOODMINUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_decrease" value = 2 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_prosperity } }
			custom_tooltip = { text = PROSPERITYFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_prosperity } set_variable = { which = "faction_mood_increase" value = 2 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } }
	}
	option = {
		name = "EVTOPTB_Plus_704" #Tell them to move on
		ai_chance = {
			factor = 25
		}
		prestige = 10
		set_character_flag = jews_not_welcome
		hidden_tooltip = {
			random = {
				chance = 75
				333 = { change_variable = { which = "jewish_refugees" value = 1 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_tradition } }
			custom_tooltip = { text = TRADITIONFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_increase" value = 2 } }
				character_event = { id = PlusFaction.200 days = 1 }
			}
		}
	}
}

# Vassal informed that liege wants jews expelled
character_event = {
	id = Plus.705 #formerly 1000182989
	desc = "EVTDESC_Plus_705"
	picture = "GFX_evt_burning_house"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_705" #Bow to his demands
		ai_chance = {
			factor = 100
		}
		any_demesne_title = {
			limit = {
				tier = BARON 
				has_building = ct_jewish_community_3
			}
			remove_building = ct_jewish_community_3
			FROM = { piety = -30 wealth = 150 }
			hidden_tooltip = {
				333 = { change_variable = { which = "jewish_refugees" value = 2 } }
			}
		}
		any_demesne_title = {
			limit = {
				tier = BARON 
				NOT = { has_building = ct_jewish_community_3 }
				has_building = ct_jewish_community_2
			}
			remove_building = ct_jewish_community_2
			FROM = { piety = -20 wealth = 100 }
			hidden_tooltip = {
				333 = { change_variable = { which = "jewish_refugees" value = 2 } }
			}
		}
		any_demesne_title = {
			limit = {
				tier = BARON 
				NOT = { has_building = ct_jewish_community_3 }
				NOT = { has_building = ct_jewish_community_2 }
				has_building = ct_jewish_community_1
			}
			remove_building = ct_jewish_community_1
			FROM = { piety = -10 wealth = 50 }
			hidden_tooltip = {
				333 = { change_variable = { which = "jewish_refugees" value = 2 } }
			}
		}
		any_courtier = {
			limit = { religion_group = jewish_group }
			banish = yes
		}
		any_realm_lord = {
			limit = {
				tier = baron
				any_liege = { character = ROOT }
				any_demesne_title = { has_building = ct_jewish_community_1 }
			}
			any_demesne_title = {
				limit = { has_building = ct_jewish_community_3 }
				remove_building = ct_jewish_community_3
				FROM = { piety = -30 wealth = 150 }
				hidden_tooltip = {
					333 = { change_variable = { which = "jewish_refugees" value = 2 } }
				}
			}
			any_demesne_title = {
				limit = {
					NOT = { has_building = ct_jewish_community_3 }
					has_building = ct_jewish_community_2
				}
				remove_building = ct_jewish_community_2
				FROM = { piety = -20 wealth = 100 }
				hidden_tooltip = {
					333 = { change_variable = { which = "jewish_refugees" value = 2 } }
				}
			}
			any_demesne_title = {
				limit = {
					NOT = { has_building = ct_jewish_community_3 }
					NOT = { has_building = ct_jewish_community_2 }
					has_building = ct_jewish_community_1
				}
				remove_building = ct_jewish_community_1
				FROM = { piety = -10 wealth = 50 }
				hidden_tooltip = {
					333 = { change_variable = { which = "jewish_refugees" value = 2 } }
				}
			}
			any_courtier = {
				limit = { religion_group = jewish_group }
				banish = yes
			}
		}
	}
	option = {
		name = "EVTOPTB_Plus_705" #Never!
		ai_chance = {
			factor = 0
		}
		FROM = {
			reverse_war = {
				target = ROOT
				casus_belli = overthrow_ruler
			}
		}
	}
}

