﻿form_polish_commonwealth_scripted_effect = {
	save_scope_as = scoped_ruler

	title:e_polish_commonwealth = { save_scope_as = polish_commonwealth }

	title:k_galicia_volhynia = { set_de_jure_liege_title = title:e_polish_commonwealth }
	title:k_lithuania        = { set_de_jure_liege_title = title:e_polish_commonwealth }
	title:k_poland           = { set_de_jure_liege_title = title:e_polish_commonwealth }

	create_title_and_vassal_change = {
		type = created
		save_scope_as = change
		add_claim_on_loss = no
	}

	title:e_polish_commonwealth = {
		change_title_holder = {
			holder = ROOT
			change = scope:change
		}
	}

	resolve_title_and_vassal_change = scope:change

	ROOT = {
		add_character_modifier = disicion_cpl_modifier
	}

	hidden_effect = {
		set_primary_title_to = title:e_polish_commonwealth
	}

	add_prestige = 500

	if = {
		limit = {
			OR = {
				has_realm_law = crown_authority_0
				has_realm_law = crown_authority_1
				has_realm_law = crown_authority_2
			}
		}
		add_realm_law_skip_effects = crown_authority_3
	}

	set_global_variable = {
		name = formed_polish_commonwealth
		value = yes
	}
}
