story_hasan = {
	# by James Beaumont
	visible = yes
	icon = {
		trigger = {
			always = yes
		}
		reference = "gfx/interface/icons/regimenttypes/mubarizun.dds"
	}
	visualization = {
		decisions = {
			hasan_evangelize_the_faith
			hasan_agitate_the_populace
			hasan_ignite_the_flames
			hasan_found_the_assassins
			hasan_expand_the_assassins
			zealous_missionary_prep_decision
		}
		basic_counter = {
			variable_name = "radical_points"
			min = 0
			max = 15
			label = "PROGRESS_TOWARDS_ASSASSIN_PATH"
		}
		character = {
			variable_name = "ultimate_foe"
			label = "ULTIMATE_FOE"
		}
	}
	on_setup = {
		
	}
#
	on_end = {
		debug_log = "Hasan i Sabbah story ended on:"
		debug_log_date = yes
	}
#
	on_owner_death = {
		end_story = yes
	}


	# Progress on Assassing path Events
	effect_group = {
		months = 6

		first_valid = {
			triggered_effect = {
				trigger = {
					exists = var:radical_points
					var:radical_points >= 5
					story_owner = {
						OR = {
							faith = faith:ismaili
							faith = faith:nizari
						}
						NOR = {
							has_character_flag = arrived_in_egypt
							has_character_flag = had_hasan_sabah_20
						}
					}
				}
				effect = {
					story_owner = {
						trigger_event = hasan_sabbah.1020
					}
				}
			}
			triggered_effect = {
				trigger = {
					exists = var:radical_points
					var:radical_points >= 15
					NOT = { exists = var:ultimate_foe }
				}
				effect = {
					story_owner = {
						trigger_event = hasan_sabbah.1031
					}
				}
			}
			triggered_effect = {
				trigger = {
					exists = var:story_phase
					var:story_phase >= 2
					NOT = { exists = var:ultimate_foe }
					story_owner.domicile.domicile_location.county.holder ?= {
						save_temporary_scope_as = county_holder
					}
					faith:ismaili = {
						religious_head = {
							save_temporary_scope_as = ismaili_hof
							NOR = {
								this = scope:county_holder
								scope:county_holder = {
									any_liege_or_above = {
										this = scope:ismaili_hof
									}
								}
							}
						}
					}
					faith:nizari = {
						religious_head = {
							save_temporary_scope_as = nizari_hof
							NOR = {
								this = scope:county_holder
								scope:county_holder = {
									any_liege_or_above = {
										this = scope:nizari_hof
									}
								}
							}
						}
					}
				}
				effect = {
					story_owner = {
						domicile.domicile_location = {
							save_scope_as = location	
						}
						trigger_event = hasan_sabbah.1031
					}
				}
			}
		}
	}

	# Hasan dies or stops being muslim, end the story
	effect_group = {
		days = { 40 60 }

		first_valid = {
			triggered_effect = {
				trigger = {
					OR = {
						# Standard checks
						NOT = { exists = story_owner }
						story_owner = {
							is_alive = no
						}
						# Must be Muslim
						NOT = { story_owner = { religion = religion:islam_religion } }
						# Must be landless
						NOT = { story_owner = { has_government = landless_adventurer_government } }
						# Must not be Sunni
						story_owner = { faith = { has_doctrine = muhammad_succession_sunni_doctrine } }
					}
				}
				effect = {
					end_story = yes
				}
			}
		}
	}
}
