namespace = HFP

#on_game_started: on new playthrough, set all Baltic and African tribal rulers and custom religions with ancestor worship (and tribalism) to use Eldership.
character_event = {
	id = HFP.24025
	hide_window = yes
	
	only_rulers = yes

	is_triggered_only = yes

	trigger = {
		is_save_game = no
        OR = {
            is_tribal = yes #Can be used by feudals, but only tribals should start with it.
            AND = {
                is_feudal = yes
                OR = {
                    religion = bori
                    religion = a_tag_roog
                    religion = a_tag_roog_reformed
                    culture = kanuri
                }
            }
        }
		is_landed = yes
		has_dlc = "Holy Fury"
		primary_title = {
			holder_scope = {
				is_nomadic = no
				OR = {
					independent = yes
					NOT = {
						any_liege = {
							holy_order = yes
						}
					}
				}
				NOR = { 
                    AND = {
                        religion_group = muslim 
                        NOT = { culture = kanuri }
                    }
					has_religion_feature = religion_matriarchal
					has_religion_feature = religion_patriarchal
				}
				is_merchant_republic = no
				is_patrician = no
				OR = {
					independent = yes
					NOT = {
						any_demesne_title = {
							is_vice_royalty = yes
						}
					}
				}
			}
			rebel = no
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
			holder_scope = {
				OR = {
					AND = {
						is_tribal = yes
						religion = baltic_pagan
					}
					AND = {
						is_tribal = yes
						religion = west_african_pagan
					}
                    religion = bori
                    religion = a_tag_roog
                    culture = kanuri
					has_religion_feature = religion_beatification
					has_religion_feature = religion_feature_baltic
					has_religion_feature = religion_feature_west_african
                    has_religion_feature = religion_feature_a_tag_roog
				}
			}
		}
	}

	immediate = {
		ROOT = { 
			any_demesne_title = { #First apply law.
				add_law = {
					law = succ_eldership
					cooldown = no
					opinion_effect = no
				}
			}
			#Then create grumpy Elder characters, so you are not without electors on start.
			spawn_elder_effect = yes
			spawn_elder_effect = yes
			spawn_elder_effect = yes
			spawn_elder_effect = yes
			spawn_elder_effect = yes
			spawn_elder_effect = yes
		}
	}
}