﻿start_grand_council_councillor_effect = {
	# Check that root does not have the active_succession_crisis flag before searching for a vassal
	if = {
		limit = {
			NOT = { has_character_flag = active_succession_crisis }
		}
		
		# 1. Grab a random vassal who is not human, at least county tier, is not root, and not a rebel
		random_vassal = {
			limit = {
				NOT = { this = root }
				is_ai = yes
				highest_held_title_tier >= tier_county
				NOT = { has_character_flag = active_crisis_rebel }
			}
			save_scope_as = target_vassal
		}

		# 2. Set location and host activity if a vassal was found
		if = {
			limit = { exists = scope:target_vassal }
			scope:target_vassal = {
				set_location = root.location
				add_character_flag = council_host_flag
				
				if = {
					limit = { exists = scope:claimant }
					set_variable = {
						name = grand_council_special_guest
						value = scope:claimant
					}
				}
				
				ai_attempt_to_host_activity = activity_grand_council
				debug_log = "AI attempted to host a Supreme Council"
				debug_log_scopes = yes
			}
		}
	}
}