﻿oathbound_remove_all_vars = {
    picture = {
        reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
    }
	title = oathbound_remove_all_vars_title
	desc = oathbound_remove_all_vars_desc

    ai_check_interval = 0

	is_shown = {
		#has_trait = oathkeeper
        #is_ai = no
        always = no
	}

	effect = {
		# Clear Boss Flags (if boss exists)
        # Transfer the vassal over to their new liege.
        create_title_and_vassal_change = {
            type = granted
            save_scope_as = change
            add_claim_on_loss = no
        }
        root = {
            change_liege = {
                liege = var:val_oathholder
                change = scope:change
            }
        }
        resolve_title_and_vassal_change = scope:change


        remove_relation_oathholder = var:val_oathholder

        remove_trait = oathkeeper

        var:val_oathholder = {
            remove_trait = oathholder_male
            remove_trait = oathholder_female
        }



		if = {
			limit = { exists = var:val_oathholder }
			var:val_oathholder = {
				remove_character_flag = oathholder_travel_job_set
				remove_character_flag = oathholder_stationary_job_set
				remove_character_flag = oathholder_sway_job_set
				remove_character_flag = oathholder_kill_job_set
				remove_character_flag = oathholder_duel_job_set
				remove_character_flag = oathholder_prefers_duel
				remove_character_flag = oathholder_prefers_murder
                remove_character_flag = i_decided_kill_type
			}
		}

		# Specifically target the task county if it exists as a variable
		if = {
			limit = { has_variable = oathbound_control_task_county_var }
			var:oathbound_control_task_county_var = {
				remove_county_modifier = oathbound_enforcing_order_weak
				remove_county_modifier = oathbound_enforcing_order_normal
				remove_county_modifier = oathbound_enforcing_order_strong
			}
		}

        remove_variable = oathbound_patrolled_county_var
		remove_variable = oathbound_control_task_county_var
		remove_variable = temp_patrol_effectiveness

        # Clear Character Variables
		remove_variable = val_oathholder
		remove_variable = val_oathkeeper
		remove_variable = val_oathholder_heir
		remove_variable = oathbound_sway_task_target_var
		remove_variable = oathbound_kill_task_target_var
		remove_variable = oathbound_duel_task_target_var

		# Clear Character Flags
		remove_character_flag = oathbound_on_travel_job
		remove_character_flag = oathbound_control_job
		remove_character_flag = oathbound_on_stationary_job
		remove_character_flag = oathbound_sway_job
		remove_character_flag = oathbound_kill_job
		remove_character_flag = oathbound_duel_job
		remove_character_flag = oathbound_kill_scheme_discovered


		send_interface_toast = {
			title = oathbound_debug_cleanup_complete_toast
			custom_tooltip = oathbound_debug_cleanup_complete_desc
		}
	}
}
