﻿# Custom modifier tab: Divine Grace (By God Alone). Same pinned routing as the other custom modifiers.
DI_add_modifier_DI_divine_grace = {
    scope = character

    effect = {
        save_scope_as = target
        random_owned_story = {
            limit = {
                story_type = DI_misc_variables_story
            }
            save_scope_as = DI_story
        }

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }

            every_living_character = {
                limit = {
                    has_character_flag = pinned_for_edit
                }

                add_character_modifier = DI_divine_grace
            }
        }
        else = {
            add_character_modifier = DI_divine_grace
        }
    }
}

DI_remove_modifier_DI_divine_grace = {
    scope = character

    effect = {
        random_owned_story = {
            limit = {
                story_type = DI_misc_variables_story
            }
            save_scope_as = DI_story
        }

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }

            every_living_character = {
                limit = {
                    has_character_flag = pinned_for_edit
                }

                remove_character_modifier = DI_divine_grace
            }
        }
        else = {
            remove_character_modifier = DI_divine_grace
        }
    }
}
