﻿# AUTO-GENERATED by DI Updater Tool - do not edit by hand
# Helpers for Title Manager building operations

DI_tm_select_building_level_1_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 1 }
    }
}

DI_tm_building_level_1_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }
}

DI_tm_select_building_level_2_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 2 }
    }
}

DI_tm_building_level_2_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 2
    }
}

DI_tm_select_building_level_3_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 3 }
    }
}

DI_tm_building_level_3_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 3
    }
}

DI_tm_select_building_level_4_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 4 }
    }
}

DI_tm_building_level_4_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 4
    }
}

DI_tm_select_building_level_5_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 5 }
    }
}

DI_tm_building_level_5_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 5
    }
}

DI_tm_select_building_level_6_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 6 }
    }
}

DI_tm_building_level_6_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 6
    }
}

DI_tm_select_building_level_7_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 7 }
    }
}

DI_tm_building_level_7_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 7
    }
}

DI_tm_select_building_level_8_sgui = {
    scope = character # Player Character

    effect = {
        set_variable = { name = DI_title_manager_building_level value = 8 }
    }
}

DI_tm_building_level_8_selected_sgui = {
    scope = character # Player Character

    is_valid = {
        var:DI_title_manager_building_level = 8
    }
}

DI_tm_building_capital_bureau_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = capital_bureau_01 }
                    }
                    add_building = capital_bureau_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = capital_bureau_02 }
                    }
                    add_building = capital_bureau_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = capital_bureau_03 }
                    }
                    add_building = capital_bureau_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = capital_bureau_04 }
                    }
                    add_building = capital_bureau_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = capital_bureau_05 }
                    }
                    add_building = capital_bureau_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = capital_bureau_06 }
                    }
                    add_building = capital_bureau_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = capital_bureau_07 }
                    }
                    add_building = capital_bureau_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = capital_bureau_08 }
                    }
                    add_building = capital_bureau_08
                }
            }
        }
    }
}

DI_tm_destroy_building_capital_bureau_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = capital_bureau }
            }
        }
    }
}

DI_tm_building_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = castle_01 }
                    }
                    set_holding_type = castle_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = castle_01 }
                    }
                    add_building = castle_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = castle_02 }
                    }
                    add_building = castle_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = castle_03 }
                    }
                    add_building = castle_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = castle_04 }
                    }
                    add_building = castle_04
                }
            }
        }
    }
}

DI_tm_destroy_building_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = castle_04 } remove_building = castle_04 }
                else_if = { limit = { has_building = castle_03 } remove_building = castle_03 }
                else_if = { limit = { has_building = castle_02 } remove_building = castle_02 }
                else_if = { limit = { has_building = castle_01 } remove_building = castle_01 }
            }
        }
    }
}

DI_tm_building_city_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = city_01 }
                    }
                    set_holding_type = city_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = city_01 }
                    }
                    add_building = city_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = city_02 }
                    }
                    add_building = city_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = city_03 }
                    }
                    add_building = city_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = city_04 }
                    }
                    add_building = city_04
                }
            }
        }
    }
}

DI_tm_destroy_building_city_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = city_04 } remove_building = city_04 }
                else_if = { limit = { has_building = city_03 } remove_building = city_03 }
                else_if = { limit = { has_building = city_02 } remove_building = city_02 }
                else_if = { limit = { has_building = city_01 } remove_building = city_01 }
            }
        }
    }
}

DI_tm_building_guild_halls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = guild_halls_01 }
                    }
                    add_building = guild_halls_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = guild_halls_02 }
                    }
                    add_building = guild_halls_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = guild_halls_03 }
                    }
                    add_building = guild_halls_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = guild_halls_04 }
                    }
                    add_building = guild_halls_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = guild_halls_05 }
                    }
                    add_building = guild_halls_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = guild_halls_06 }
                    }
                    add_building = guild_halls_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = guild_halls_07 }
                    }
                    add_building = guild_halls_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = guild_halls_08 }
                    }
                    add_building = guild_halls_08
                }
            }
        }
    }
}

DI_tm_destroy_building_guild_halls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = guild_halls }
            }
        }
    }
}

DI_tm_building_hospices_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hospices_01 }
                    }
                    add_building = hospices_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hospices_02 }
                    }
                    add_building = hospices_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hospices_03 }
                    }
                    add_building = hospices_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hospices_04 }
                    }
                    add_building = hospices_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hospices_05 }
                    }
                    add_building = hospices_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = hospices_06 }
                    }
                    add_building = hospices_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = hospices_07 }
                    }
                    add_building = hospices_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = hospices_08 }
                    }
                    add_building = hospices_08
                }
            }
        }
    }
}

DI_tm_destroy_building_hospices_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = hospices }
            }
        }
    }
}

DI_tm_building_dragon_kiln_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dragon_kiln_01 }
                    }
                    add_building = dragon_kiln_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = dragon_kiln_02 }
                    }
                    add_building = dragon_kiln_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = dragon_kiln_03 }
                    }
                    add_building = dragon_kiln_03
                }
            }
        }
    }
}

DI_tm_destroy_building_dragon_kiln_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dragon_kiln_03 } remove_building = dragon_kiln_03 }
                else_if = { limit = { has_building = dragon_kiln_02 } remove_building = dragon_kiln_02 }
                else_if = { limit = { has_building = dragon_kiln_01 } remove_building = dragon_kiln_01 }
            }
        }
    }
}

DI_tm_building_examination_hall_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = examination_hall_01 }
                    }
                    add_building = examination_hall_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = examination_hall_02 }
                    }
                    add_building = examination_hall_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = examination_hall_03 }
                    }
                    add_building = examination_hall_03
                }
            }
        }
    }
}

DI_tm_destroy_building_examination_hall_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = examination_hall_03 } remove_building = examination_hall_03 }
                else_if = { limit = { has_building = examination_hall_02 } remove_building = examination_hall_02 }
                else_if = { limit = { has_building = examination_hall_01 } remove_building = examination_hall_01 }
            }
        }
    }
}

DI_tm_building_tower_of_silence_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tower_of_silence_01 }
                    }
                    add_building = tower_of_silence_01
                }
            }
        }
    }
}

DI_tm_destroy_building_tower_of_silence_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tower_of_silence_01 } remove_building = tower_of_silence_01 }
            }
        }
    }
}

DI_tm_building_charnel_grounds_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = charnel_grounds_01 }
                    }
                    add_building = charnel_grounds_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = charnel_grounds_02 }
                    }
                    add_building = charnel_grounds_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = charnel_grounds_03 }
                    }
                    add_building = charnel_grounds_03
                }
            }
        }
    }
}

DI_tm_destroy_building_charnel_grounds_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = charnel_grounds_03 } remove_building = charnel_grounds_03 }
                else_if = { limit = { has_building = charnel_grounds_02 } remove_building = charnel_grounds_02 }
                else_if = { limit = { has_building = charnel_grounds_01 } remove_building = charnel_grounds_01 }
            }
        }
    }
}

DI_tm_building_burial_site_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = burial_site_01 }
                    }
                    add_building = burial_site_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = burial_site_02 }
                    }
                    add_building = burial_site_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = burial_site_03 }
                    }
                    add_building = burial_site_03
                }
            }
        }
    }
}

DI_tm_destroy_building_burial_site_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = burial_site_03 } remove_building = burial_site_03 }
                else_if = { limit = { has_building = burial_site_02 } remove_building = burial_site_02 }
                else_if = { limit = { has_building = burial_site_01 } remove_building = burial_site_01 }
            }
        }
    }
}

DI_tm_building_royal_garden_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = royal_garden_01 }
                    }
                    add_building = royal_garden_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = royal_garden_02 }
                    }
                    add_building = royal_garden_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = royal_garden_03 }
                    }
                    add_building = royal_garden_03
                }
            }
        }
    }
}

DI_tm_destroy_building_royal_garden_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = royal_garden_03 } remove_building = royal_garden_03 }
                else_if = { limit = { has_building = royal_garden_02 } remove_building = royal_garden_02 }
                else_if = { limit = { has_building = royal_garden_01 } remove_building = royal_garden_01 }
            }
        }
    }
}

DI_tm_building_military_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = military_academy_01 }
                    }
                    add_building = military_academy_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = military_academy_02 }
                    }
                    add_building = military_academy_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = military_academy_03 }
                    }
                    add_building = military_academy_03
                }
            }
        }
    }
}

DI_tm_destroy_building_military_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = military_academy_03 } remove_building = military_academy_03 }
                else_if = { limit = { has_building = military_academy_02 } remove_building = military_academy_02 }
                else_if = { limit = { has_building = military_academy_01 } remove_building = military_academy_01 }
            }
        }
    }
}

DI_tm_building_march_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = march_01 }
                    }
                    add_building = march_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = march_02 }
                    }
                    add_building = march_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = march_03 }
                    }
                    add_building = march_03
                }
            }
        }
    }
}

DI_tm_destroy_building_march_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = march_03 } remove_building = march_03 }
                else_if = { limit = { has_building = march_02 } remove_building = march_02 }
                else_if = { limit = { has_building = march_01 } remove_building = march_01 }
            }
        }
    }
}

DI_tm_building_siege_works_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = siege_works_01 }
                    }
                    add_building = siege_works_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = siege_works_02 }
                    }
                    add_building = siege_works_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = siege_works_03 }
                    }
                    add_building = siege_works_03
                }
            }
        }
    }
}

DI_tm_destroy_building_siege_works_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = siege_works_03 } remove_building = siege_works_03 }
                else_if = { limit = { has_building = siege_works_02 } remove_building = siege_works_02 }
                else_if = { limit = { has_building = siege_works_01 } remove_building = siege_works_01 }
            }
        }
    }
}

DI_tm_building_royal_armory_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = royal_armory_01 }
                    }
                    add_building = royal_armory_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = royal_armory_02 }
                    }
                    add_building = royal_armory_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = royal_armory_03 }
                    }
                    add_building = royal_armory_03
                }
            }
        }
    }
}

DI_tm_destroy_building_royal_armory_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = royal_armory_03 } remove_building = royal_armory_03 }
                else_if = { limit = { has_building = royal_armory_02 } remove_building = royal_armory_02 }
                else_if = { limit = { has_building = royal_armory_01 } remove_building = royal_armory_01 }
            }
        }
    }
}

DI_tm_building_jousting_lists_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jousting_lists_01 }
                    }
                    add_building = jousting_lists_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = jousting_lists_02 }
                    }
                    add_building = jousting_lists_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = jousting_lists_03 }
                    }
                    add_building = jousting_lists_03
                }
            }
        }
    }
}

DI_tm_destroy_building_jousting_lists_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jousting_lists_03 } remove_building = jousting_lists_03 }
                else_if = { limit = { has_building = jousting_lists_02 } remove_building = jousting_lists_02 }
                else_if = { limit = { has_building = jousting_lists_01 } remove_building = jousting_lists_01 }
            }
        }
    }
}

DI_tm_building_blacksmiths_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = blacksmiths_01 }
                    }
                    add_building = blacksmiths_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = blacksmiths_02 }
                    }
                    add_building = blacksmiths_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = blacksmiths_03 }
                    }
                    add_building = blacksmiths_03
                }
            }
        }
    }
}

DI_tm_destroy_building_blacksmiths_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = blacksmiths_03 } remove_building = blacksmiths_03 }
                else_if = { limit = { has_building = blacksmiths_02 } remove_building = blacksmiths_02 }
                else_if = { limit = { has_building = blacksmiths_01 } remove_building = blacksmiths_01 }
            }
        }
    }
}

DI_tm_building_archery_ranges_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = archery_ranges_01 }
                    }
                    add_building = archery_ranges_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = archery_ranges_02 }
                    }
                    add_building = archery_ranges_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = archery_ranges_03 }
                    }
                    add_building = archery_ranges_03
                }
            }
        }
    }
}

DI_tm_destroy_building_archery_ranges_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = archery_ranges_03 } remove_building = archery_ranges_03 }
                else_if = { limit = { has_building = archery_ranges_02 } remove_building = archery_ranges_02 }
                else_if = { limit = { has_building = archery_ranges_01 } remove_building = archery_ranges_01 }
            }
        }
    }
}

DI_tm_building_tax_assessor_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tax_assessor_01 }
                    }
                    add_building = tax_assessor_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = tax_assessor_02 }
                    }
                    add_building = tax_assessor_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = tax_assessor_03 }
                    }
                    add_building = tax_assessor_03
                }
            }
        }
    }
}

DI_tm_destroy_building_tax_assessor_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tax_assessor_03 } remove_building = tax_assessor_03 }
                else_if = { limit = { has_building = tax_assessor_02 } remove_building = tax_assessor_02 }
                else_if = { limit = { has_building = tax_assessor_01 } remove_building = tax_assessor_01 }
            }
        }
    }
}

DI_tm_building_leisure_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = leisure_palace_01 }
                    }
                    add_building = leisure_palace_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = leisure_palace_02 }
                    }
                    add_building = leisure_palace_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = leisure_palace_03 }
                    }
                    add_building = leisure_palace_03
                }
            }
        }
    }
}

DI_tm_destroy_building_leisure_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = leisure_palace_03 } remove_building = leisure_palace_03 }
                else_if = { limit = { has_building = leisure_palace_02 } remove_building = leisure_palace_02 }
                else_if = { limit = { has_building = leisure_palace_01 } remove_building = leisure_palace_01 }
            }
        }
    }
}

DI_tm_building_royal_forest_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = royal_forest_01 }
                    }
                    add_building = royal_forest_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = royal_forest_02 }
                    }
                    add_building = royal_forest_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = royal_forest_03 }
                    }
                    add_building = royal_forest_03
                }
            }
        }
    }
}

DI_tm_destroy_building_royal_forest_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = royal_forest_03 } remove_building = royal_forest_03 }
                else_if = { limit = { has_building = royal_forest_02 } remove_building = royal_forest_02 }
                else_if = { limit = { has_building = royal_forest_01 } remove_building = royal_forest_01 }
            }
        }
    }
}

DI_tm_building_great_megalith_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = great_megalith_01 }
                    }
                    add_building = great_megalith_01
                }
            }
        }
    }
}

DI_tm_destroy_building_great_megalith_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = great_megalith_01 } remove_building = great_megalith_01 }
            }
        }
    }
}

DI_tm_building_legendary_shrine_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = legendary_shrine }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_shrine
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_shrine
                }
            }
        }
    }
}

DI_tm_destroy_building_legendary_shrine_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = legendary_shrine } remove_building = legendary_shrine }
            }
        }
    }
}

DI_tm_building_legendary_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = legendary_palace }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_palace
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_palace
                }
            }
        }
    }
}

DI_tm_destroy_building_legendary_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = legendary_palace } remove_building = legendary_palace }
            }
        }
    }
}

DI_tm_building_legendary_statue_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = legendary_statue }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_statue
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_statue
                }
            }
        }
    }
}

DI_tm_destroy_building_legendary_statue_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = legendary_statue } remove_building = legendary_statue }
            }
        }
    }
}

DI_tm_building_legendary_watchtower_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = legendary_watchtower }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_watchtower
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_watchtower
                }
            }
        }
    }
}

DI_tm_destroy_building_legendary_watchtower_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = legendary_watchtower } remove_building = legendary_watchtower }
            }
        }
    }
}

DI_tm_building_legendary_hunting_lodge_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = legendary_hunting_lodge }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_hunting_lodge
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_hunting_lodge
                }
            }
        }
    }
}

DI_tm_destroy_building_legendary_hunting_lodge_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = legendary_hunting_lodge } remove_building = legendary_hunting_lodge }
            }
        }
    }
}

DI_tm_building_nomadic_camp_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = nomadic_camp_01 }
                    }
                    set_holding_type = nomad_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = nomadic_camp_01 }
                    }
                    add_building = nomadic_camp_01
                }
            }
        }
    }
}

DI_tm_destroy_building_nomadic_camp_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = nomadic_camp_01 } remove_building = nomadic_camp_01 }
            }
        }
    }
}

DI_tm_building_herder_camp_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = herder_camp_01 }
                    }
                    set_holding_type = herder_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = herder_camp_01 }
                    }
                    add_building = herder_camp_01
                }
            }
        }
    }
}

DI_tm_destroy_building_herder_camp_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = herder_camp_01 } remove_building = herder_camp_01 }
            }
        }
    }
}

DI_tm_building_holy_site_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_cathedral_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_cathedral_01 } remove_building = holy_site_cathedral_01 }
            }
        }
    }
}

DI_tm_building_holy_site_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_mosque_01 } remove_building = holy_site_mosque_01 }
            }
        }
    }
}

DI_tm_building_holy_site_fire_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_fire_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_fire_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_fire_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_fire_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_fire_temple_01 } remove_building = holy_site_fire_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_pagan_grand_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_pagan_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_pagan_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_pagan_grand_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_pagan_grand_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_pagan_grand_temple_01 } remove_building = holy_site_pagan_grand_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_indian_grand_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_indian_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_indian_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_indian_grand_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_indian_grand_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_indian_grand_temple_01 } remove_building = holy_site_indian_grand_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_buddhist_grand_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_buddhist_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_buddhist_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_buddhist_grand_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_buddhist_grand_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_buddhist_grand_temple_01 } remove_building = holy_site_buddhist_grand_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_japanese_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_japanese_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_japanese_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_japanese_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_japanese_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_japanese_temple_01 } remove_building = holy_site_japanese_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_chinese_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_chinese_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_chinese_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_chinese_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_chinese_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_chinese_temple_01 } remove_building = holy_site_chinese_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_se_asia_pagan_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_se_asia_pagan_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_se_asia_pagan_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_se_asia_pagan_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_se_asia_pagan_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_se_asia_pagan_temple_01 } remove_building = holy_site_se_asia_pagan_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_other_grand_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_other_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_other_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_other_grand_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_other_grand_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_other_grand_temple_01 } remove_building = holy_site_other_grand_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_mahabodhi_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_mahabodhi_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_mahabodhi_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_mahabodhi_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_mahabodhi_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_mahabodhi_temple_01 } remove_building = holy_site_mahabodhi_temple_01 }
            }
        }
    }
}

DI_tm_building_holy_site_imam_ali_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_imam_ali_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_imam_ali_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_imam_ali_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_imam_ali_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_imam_ali_mosque_01 } remove_building = holy_site_imam_ali_mosque_01 }
            }
        }
    }
}

DI_tm_building_holy_site_great_mosque_of_mecca_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_great_mosque_of_mecca_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_mecca_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_mecca_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_great_mosque_of_mecca_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_great_mosque_of_mecca_01 } remove_building = holy_site_great_mosque_of_mecca_01 }
            }
        }
    }
}

DI_tm_building_holy_site_great_mosque_of_cordoba_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_great_mosque_of_cordoba_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_cordoba_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_cordoba_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_great_mosque_of_cordoba_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_great_mosque_of_cordoba_01 } remove_building = holy_site_great_mosque_of_cordoba_01 }
            }
        }
    }
}

DI_tm_building_holy_site_great_mosque_of_djenne_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_great_mosque_of_djenne_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_djenne_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_djenne_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_great_mosque_of_djenne_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_great_mosque_of_djenne_01 } remove_building = holy_site_great_mosque_of_djenne_01 }
            }
        }
    }
}

DI_tm_building_holy_site_great_mosque_of_samarra_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_great_mosque_of_samarra_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_samarra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_samarra_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_great_mosque_of_samarra_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_great_mosque_of_samarra_01 } remove_building = holy_site_great_mosque_of_samarra_01 }
            }
        }
    }
}

DI_tm_building_holy_site_cologne_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_cologne_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_cologne_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_cologne_cathedral_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_cologne_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_cologne_cathedral_01 } remove_building = holy_site_cologne_cathedral_01 }
            }
        }
    }
}

DI_tm_building_holy_site_canterbury_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_canterbury_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_canterbury_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_canterbury_cathedral_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = holy_site_canterbury_cathedral_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_canterbury_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_canterbury_cathedral_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = holy_site_canterbury_cathedral_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_canterbury_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_canterbury_cathedral_03
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_canterbury_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_canterbury_cathedral_03 } remove_building = holy_site_canterbury_cathedral_03 }
                else_if = { limit = { has_building = holy_site_canterbury_cathedral_02 } remove_building = holy_site_canterbury_cathedral_02 }
                else_if = { limit = { has_building = holy_site_canterbury_cathedral_01 } remove_building = holy_site_canterbury_cathedral_01 }
            }
        }
    }
}

DI_tm_building_holy_site_prophetic_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_prophetic_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_prophetic_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_prophetic_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_prophetic_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_prophetic_mosque_01 } remove_building = holy_site_prophetic_mosque_01 }
            }
        }
    }
}

DI_tm_building_doges_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = doges_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = doges_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = doges_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_doges_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = doges_palace_01 } remove_building = doges_palace_01 }
            }
        }
    }
}

DI_tm_building_walls_of_genoa_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = walls_of_genoa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = walls_of_genoa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = walls_of_genoa_01
                }
            }
        }
    }
}

DI_tm_destroy_building_walls_of_genoa_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = walls_of_genoa_01 } remove_building = walls_of_genoa_01 }
            }
        }
    }
}

DI_tm_building_visby_ringmur_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = visby_ringmur_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = visby_ringmur_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = visby_ringmur_01
                }
            }
        }
    }
}

DI_tm_destroy_building_visby_ringmur_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = visby_ringmur_01 } remove_building = visby_ringmur_01 }
            }
        }
    }
}

DI_tm_building_walls_of_benin_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = walls_of_benin_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = walls_of_benin_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = walls_of_benin_01
                }
            }
        }
    }
}

DI_tm_destroy_building_walls_of_benin_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = walls_of_benin_01 } remove_building = walls_of_benin_01 }
            }
        }
    }
}

DI_tm_building_theodosian_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = theodosian_walls_01 }
                    }
                    add_building = theodosian_walls_01
                }
            }
        }
    }
}

DI_tm_destroy_building_theodosian_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = theodosian_walls_01 } remove_building = theodosian_walls_01 }
            }
        }
    }
}

DI_tm_building_aurelian_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = aurelian_walls_01 }
                    }
                    add_building = aurelian_walls_01
                }
            }
        }
    }
}

DI_tm_destroy_building_aurelian_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = aurelian_walls_01 } remove_building = aurelian_walls_01 }
            }
        }
    }
}

DI_tm_building_the_colosseum_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_colosseum_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_colosseum_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_colosseum_01
                }
            }
        }
    }
}

DI_tm_destroy_building_the_colosseum_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_colosseum_01 } remove_building = the_colosseum_01 }
            }
        }
    }
}

DI_tm_building_iron_pillar_of_delhi_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = iron_pillar_of_delhi_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_pillar_of_delhi_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_pillar_of_delhi_01
                }
            }
        }
    }
}

DI_tm_destroy_building_iron_pillar_of_delhi_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = iron_pillar_of_delhi_01 } remove_building = iron_pillar_of_delhi_01 }
            }
        }
    }
}

DI_tm_building_iron_pillar_of_dhar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = iron_pillar_of_dhar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_pillar_of_dhar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_pillar_of_dhar_01
                }
            }
        }
    }
}

DI_tm_destroy_building_iron_pillar_of_dhar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = iron_pillar_of_dhar_01 } remove_building = iron_pillar_of_dhar_01 }
            }
        }
    }
}

DI_tm_building_the_pyramids_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_pyramids_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_pyramids_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_pyramids_01
                }
            }
        }
    }
}

DI_tm_destroy_building_the_pyramids_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_pyramids_01 } remove_building = the_pyramids_01 }
            }
        }
    }
}

DI_tm_building_stonehenge_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = stonehenge_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = stonehenge_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = stonehenge_01
                }
            }
        }
    }
}

DI_tm_destroy_building_stonehenge_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = stonehenge_01 } remove_building = stonehenge_01 }
            }
        }
    }
}

DI_tm_building_offas_dyke_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = offas_dyke_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = offas_dyke_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = offas_dyke_01
                }
            }
        }
    }
}

DI_tm_destroy_building_offas_dyke_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = offas_dyke_01 } remove_building = offas_dyke_01 }
            }
        }
    }
}

DI_tm_building_hadrians_wall_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hadrians_wall_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hadrians_wall_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hadrians_wall_01
                }
            }
        }
    }
}

DI_tm_destroy_building_hadrians_wall_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hadrians_wall_01 } remove_building = hadrians_wall_01 }
            }
        }
    }
}

DI_tm_building_petra_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = petra_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = petra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = petra_01
                }
            }
        }
    }
}

DI_tm_destroy_building_petra_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = petra_01 } remove_building = petra_01 }
            }
        }
    }
}

DI_tm_building_buddhas_of_bamian_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = buddhas_of_bamian_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = buddhas_of_bamian_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = buddhas_of_bamian_01
                }
            }
        }
    }
}

DI_tm_destroy_building_buddhas_of_bamian_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = buddhas_of_bamian_01 } remove_building = buddhas_of_bamian_01 }
            }
        }
    }
}

DI_tm_building_alhambra_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = alhambra_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alhambra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alhambra_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = alhambra_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alhambra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alhambra_02
                }
            }
        }
    }
}

DI_tm_destroy_building_alhambra_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = alhambra_02 } remove_building = alhambra_02 }
                else_if = { limit = { has_building = alhambra_01 } remove_building = alhambra_01 }
            }
        }
    }
}

DI_tm_building_citadel_of_aleppo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = citadel_of_aleppo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_of_aleppo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_of_aleppo_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = citadel_of_aleppo_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_of_aleppo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_of_aleppo_02
                }
            }
        }
    }
}

DI_tm_destroy_building_citadel_of_aleppo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = citadel_of_aleppo_02 } remove_building = citadel_of_aleppo_02 }
                else_if = { limit = { has_building = citadel_of_aleppo_01 } remove_building = citadel_of_aleppo_01 }
            }
        }
    }
}

DI_tm_building_house_of_wisdom_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = house_of_wisdom_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = house_of_wisdom_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = house_of_wisdom_01
                }
            }
        }
    }
}

DI_tm_destroy_building_house_of_wisdom_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = house_of_wisdom_01 } remove_building = house_of_wisdom_01 }
            }
        }
    }
}

DI_tm_building_the_tower_of_london_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_tower_of_london_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_tower_of_london_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_tower_of_london_01
                }
            }
        }
    }
}

DI_tm_destroy_building_the_tower_of_london_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_tower_of_london_01 } remove_building = the_tower_of_london_01 }
            }
        }
    }
}

DI_tm_building_london_bridge_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = london_bridge_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = london_bridge_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = london_bridge_01
                }
            }
        }
    }
}

DI_tm_destroy_building_london_bridge_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = london_bridge_01 } remove_building = london_bridge_01 }
            }
        }
    }
}

DI_tm_building_notre_dame_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = notre_dame_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = notre_dame_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = notre_dame_01
                }
            }
        }
    }
}

DI_tm_destroy_building_notre_dame_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = notre_dame_01 } remove_building = notre_dame_01 }
            }
        }
    }
}

DI_tm_building_brihadeeswarar_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = brihadeeswarar_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = brihadeeswarar_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = brihadeeswarar_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_brihadeeswarar_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = brihadeeswarar_temple_01 } remove_building = brihadeeswarar_temple_01 }
            }
        }
    }
}

DI_tm_building_shwedagon_pagoda_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = shwedagon_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shwedagon_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shwedagon_pagoda_01
                }
            }
        }
    }
}

DI_tm_destroy_building_shwedagon_pagoda_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = shwedagon_pagoda_01 } remove_building = shwedagon_pagoda_01 }
            }
        }
    }
}

DI_tm_building_ananda_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ananda_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ananda_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ananda_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_ananda_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ananda_temple_01 } remove_building = ananda_temple_01 }
            }
        }
    }
}

DI_tm_building_the_friday_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_friday_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_friday_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_friday_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_the_friday_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_friday_mosque_01 } remove_building = the_friday_mosque_01 }
            }
        }
    }
}

DI_tm_building_khajuraho_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = khajuraho_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khajuraho_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khajuraho_01
                }
            }
        }
    }
}

DI_tm_destroy_building_khajuraho_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = khajuraho_01 } remove_building = khajuraho_01 }
            }
        }
    }
}

DI_tm_building_palace_of_aachen_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = palace_of_aachen_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = palace_of_aachen_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = palace_of_aachen_01
                }
            }
        }
    }
}

DI_tm_destroy_building_palace_of_aachen_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = palace_of_aachen_01 } remove_building = palace_of_aachen_01 }
            }
        }
    }
}

DI_tm_building_hagia_sophia_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hagia_sophia_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hagia_sophia_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hagia_sophia_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hagia_sophia_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hagia_sophia_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hagia_sophia_02
                }
            }
        }
    }
}

DI_tm_destroy_building_hagia_sophia_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hagia_sophia_02 } remove_building = hagia_sophia_02 }
                else_if = { limit = { has_building = hagia_sophia_01 } remove_building = hagia_sophia_01 }
            }
        }
    }
}

DI_tm_building_dome_of_the_rock_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dome_of_the_rock_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dome_of_the_rock_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dome_of_the_rock_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = temple_in_jerusalem_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dome_of_the_rock_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temple_in_jerusalem_01
                }
            }
        }
    }
}

DI_tm_destroy_building_dome_of_the_rock_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = temple_in_jerusalem_01 } remove_building = temple_in_jerusalem_01 }
                else_if = { limit = { has_building = dome_of_the_rock_01 } remove_building = dome_of_the_rock_01 }
            }
        }
    }
}

DI_tm_building_hall_of_heroes_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hall_of_heroes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hall_of_heroes_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hall_of_heroes_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hall_of_heroes_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hall_of_heroes_05 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_05
                }
            }
        }
    }
}

DI_tm_destroy_building_hall_of_heroes_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hall_of_heroes_05 } remove_building = hall_of_heroes_05 }
                else_if = { limit = { has_building = hall_of_heroes_04 } remove_building = hall_of_heroes_04 }
                else_if = { limit = { has_building = hall_of_heroes_03 } remove_building = hall_of_heroes_03 }
                else_if = { limit = { has_building = hall_of_heroes_02 } remove_building = hall_of_heroes_02 }
                else_if = { limit = { has_building = hall_of_heroes_01 } remove_building = hall_of_heroes_01 }
            }
        }
    }
}

DI_tm_building_generic_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = generic_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_university
                }
            }
        }
    }
}

DI_tm_destroy_building_generic_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = generic_university } remove_building = generic_university }
            }
        }
    }
}

DI_tm_building_al_azhar_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = al_azhar_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = al_azhar_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = al_azhar_university
                }
            }
        }
    }
}

DI_tm_destroy_building_al_azhar_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = al_azhar_university } remove_building = al_azhar_university }
            }
        }
    }
}

DI_tm_building_sankore_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sankore_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sankore_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sankore_university
                }
            }
        }
    }
}

DI_tm_destroy_building_sankore_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sankore_university } remove_building = sankore_university }
            }
        }
    }
}

DI_tm_building_siena_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = siena_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siena_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siena_university
                }
            }
        }
    }
}

DI_tm_destroy_building_siena_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = siena_university } remove_building = siena_university }
            }
        }
    }
}

DI_tm_building_nalanda_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = nalanda_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nalanda_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nalanda_university
                }
            }
        }
    }
}

DI_tm_destroy_building_nalanda_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = nalanda_university } remove_building = nalanda_university }
            }
        }
    }
}

DI_tm_building_special_sicilian_parliament_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = special_sicilian_parliament_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = special_sicilian_parliament_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = special_sicilian_parliament_01
                }
            }
        }
    }
}

DI_tm_destroy_building_special_sicilian_parliament_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = special_sicilian_parliament_01 } remove_building = special_sicilian_parliament_01 }
            }
        }
    }
}

DI_tm_building_special_greenhouse_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = special_greenhouse_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = special_greenhouse_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = special_greenhouse_01
                }
            }
        }
    }
}

DI_tm_destroy_building_special_greenhouse_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = special_greenhouse_01 } remove_building = special_greenhouse_01 }
            }
        }
    }
}

DI_tm_building_hotin_fort_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hotin_fort_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hotin_fort_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hotin_fort_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hotin_fort_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hotin_fort_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hotin_fort_02
                }
            }
        }
    }
}

DI_tm_destroy_building_hotin_fort_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hotin_fort_02 } remove_building = hotin_fort_02 }
                else_if = { limit = { has_building = hotin_fort_01 } remove_building = hotin_fort_01 }
            }
        }
    }
}

DI_tm_building_golden_gate_of_kiev_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = golden_gate_of_kiev_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = golden_gate_of_kiev_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = golden_gate_of_kiev_01
                }
            }
        }
    }
}

DI_tm_destroy_building_golden_gate_of_kiev_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = golden_gate_of_kiev_01 } remove_building = golden_gate_of_kiev_01 }
            }
        }
    }
}

DI_tm_building_heddal_stave_church_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = heddal_stave_church_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = heddal_stave_church_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = heddal_stave_church_01
                }
            }
        }
    }
}

DI_tm_destroy_building_heddal_stave_church_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = heddal_stave_church_01 } remove_building = heddal_stave_church_01 }
            }
        }
    }
}

DI_tm_building_temple_of_uppsala_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = temple_of_uppsala_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temple_of_uppsala_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temple_of_uppsala_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = temple_of_uppsala_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temple_of_uppsala_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temple_of_uppsala_02
                }
            }
        }
    }
}

DI_tm_destroy_building_temple_of_uppsala_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = temple_of_uppsala_02 } remove_building = temple_of_uppsala_02 }
                else_if = { limit = { has_building = temple_of_uppsala_01 } remove_building = temple_of_uppsala_01 }
            }
        }
    }
}

DI_tm_building_lund_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lund_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lund_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lund_cathedral_01
                }
            }
        }
    }
}

DI_tm_destroy_building_lund_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lund_cathedral_01 } remove_building = lund_cathedral_01 }
            }
        }
    }
}

DI_tm_building_danevirke_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = danevirke_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = danevirke_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = danevirke_01
                }
            }
        }
    }
}

DI_tm_destroy_building_danevirke_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = danevirke_01 } remove_building = danevirke_01 }
            }
        }
    }
}

DI_tm_building_roman_wall_of_lugo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = roman_wall_of_lugo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = roman_wall_of_lugo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = roman_wall_of_lugo_01
                }
            }
        }
    }
}

DI_tm_destroy_building_roman_wall_of_lugo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = roman_wall_of_lugo_01 } remove_building = roman_wall_of_lugo_01 }
            }
        }
    }
}

DI_tm_building_rock_of_gibraltar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = rock_of_gibraltar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rock_of_gibraltar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rock_of_gibraltar_01
                }
            }
        }
    }
}

DI_tm_destroy_building_rock_of_gibraltar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = rock_of_gibraltar_01 } remove_building = rock_of_gibraltar_01 }
            }
        }
    }
}

DI_tm_building_aljaferia_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = aljaferia_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = aljaferia_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = aljaferia_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_aljaferia_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = aljaferia_palace_01 } remove_building = aljaferia_palace_01 }
            }
        }
    }
}

DI_tm_building_tower_of_hercules_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tower_of_hercules_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tower_of_hercules_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tower_of_hercules_01
                }
            }
        }
    }
}

DI_tm_destroy_building_tower_of_hercules_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tower_of_hercules_01 } remove_building = tower_of_hercules_01 }
            }
        }
    }
}

DI_tm_building_city_wall_of_toledo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = city_wall_of_toledo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = city_wall_of_toledo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = city_wall_of_toledo_01
                }
            }
        }
    }
}

DI_tm_destroy_building_city_wall_of_toledo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = city_wall_of_toledo_01 } remove_building = city_wall_of_toledo_01 }
            }
        }
    }
}

DI_tm_building_alcazar_of_segovia_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = alcazar_of_segovia_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alcazar_of_segovia_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alcazar_of_segovia_01
                }
            }
        }
    }
}

DI_tm_destroy_building_alcazar_of_segovia_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = alcazar_of_segovia_01 } remove_building = alcazar_of_segovia_01 }
            }
        }
    }
}

DI_tm_building_holy_site_basilica_santiago_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_basilica_santiago_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_basilica_santiago_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_basilica_santiago_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_basilica_santiago_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_basilica_santiago_01 } remove_building = holy_site_basilica_santiago_01 }
            }
        }
    }
}

DI_tm_building_imam_reza_shrine_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = imam_reza_shrine_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = imam_reza_shrine_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = imam_reza_shrine_01
                }
            }
        }
    }
}

DI_tm_destroy_building_imam_reza_shrine_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = imam_reza_shrine_01 } remove_building = imam_reza_shrine_01 }
            }
        }
    }
}

DI_tm_building_soltaniyeh_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = soltaniyeh_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = soltaniyeh_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = soltaniyeh_01
                }
            }
        }
    }
}

DI_tm_destroy_building_soltaniyeh_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = soltaniyeh_01 } remove_building = soltaniyeh_01 }
            }
        }
    }
}

DI_tm_building_palace_of_ctesiphon_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = palace_of_ctesiphon_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = palace_of_ctesiphon_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = palace_of_ctesiphon_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = palace_of_ctesiphon_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = palace_of_ctesiphon_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = palace_of_ctesiphon_02
                }
            }
        }
    }
}

DI_tm_destroy_building_palace_of_ctesiphon_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = palace_of_ctesiphon_02 } remove_building = palace_of_ctesiphon_02 }
                else_if = { limit = { has_building = palace_of_ctesiphon_01 } remove_building = palace_of_ctesiphon_01 }
            }
        }
    }
}

DI_tm_building_falak_ol_aflak_citadel_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = falak_ol_aflak_citadel_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falak_ol_aflak_citadel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falak_ol_aflak_citadel_01
                }
            }
        }
    }
}

DI_tm_destroy_building_falak_ol_aflak_citadel_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = falak_ol_aflak_citadel_01 } remove_building = falak_ol_aflak_citadel_01 }
            }
        }
    }
}

DI_tm_building_minarets_and_remains_of_jam_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = minarets_and_remains_of_jam_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = minarets_and_remains_of_jam_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = minarets_and_remains_of_jam_01
                }
            }
        }
    }
}

DI_tm_destroy_building_minarets_and_remains_of_jam_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = minarets_and_remains_of_jam_01 } remove_building = minarets_and_remains_of_jam_01 }
            }
        }
    }
}

DI_tm_building_great_wall_of_gorgan_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = great_wall_of_gorgan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = great_wall_of_gorgan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = great_wall_of_gorgan_01
                }
            }
        }
    }
}

DI_tm_destroy_building_great_wall_of_gorgan_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = great_wall_of_gorgan_01 } remove_building = great_wall_of_gorgan_01 }
            }
        }
    }
}

DI_tm_building_maharloo_lake_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = maharloo_lake_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maharloo_lake_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maharloo_lake_01
                }
            }
        }
    }
}

DI_tm_destroy_building_maharloo_lake_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = maharloo_lake_01 } remove_building = maharloo_lake_01 }
            }
        }
    }
}

DI_tm_building_rainbow_mountains_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = rainbow_mountains_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rainbow_mountains_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rainbow_mountains_01
                }
            }
        }
    }
}

DI_tm_destroy_building_rainbow_mountains_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = rainbow_mountains_01 } remove_building = rainbow_mountains_01 }
            }
        }
    }
}

DI_tm_building_mount_damavand_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mount_damavand_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_damavand_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_damavand_01
                }
            }
        }
    }
}

DI_tm_destroy_building_mount_damavand_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mount_damavand_01 } remove_building = mount_damavand_01 }
            }
        }
    }
}

DI_tm_building_tomb_of_cyrus_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tomb_of_cyrus_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tomb_of_cyrus_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tomb_of_cyrus_01
                }
            }
        }
    }
}

DI_tm_destroy_building_tomb_of_cyrus_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tomb_of_cyrus_01 } remove_building = tomb_of_cyrus_01 }
            }
        }
    }
}

DI_tm_building_ark_of_bukhara_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ark_of_bukhara_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ark_of_bukhara_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ark_of_bukhara_01
                }
            }
        }
    }
}

DI_tm_destroy_building_ark_of_bukhara_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ark_of_bukhara_01 } remove_building = ark_of_bukhara_01 }
            }
        }
    }
}

DI_tm_building_shah_i_zinda_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = shah_i_zinda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shah_i_zinda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shah_i_zinda_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = shah_i_zinda_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shah_i_zinda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shah_i_zinda_02
                }
            }
        }
    }
}

DI_tm_destroy_building_shah_i_zinda_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = shah_i_zinda_02 } remove_building = shah_i_zinda_02 }
                else_if = { limit = { has_building = shah_i_zinda_01 } remove_building = shah_i_zinda_01 }
            }
        }
    }
}

DI_tm_building_alamut_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = alamut_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alamut_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alamut_castle_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = alamut_castle_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alamut_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alamut_castle_02
                }
            }
        }
    }
}

DI_tm_destroy_building_alamut_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = alamut_castle_02 } remove_building = alamut_castle_02 }
                else_if = { limit = { has_building = alamut_castle_01 } remove_building = alamut_castle_01 }
            }
        }
    }
}

DI_tm_building_assassin_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = assassin_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = assassin_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = assassin_castle_01
                }
            }
        }
    }
}

DI_tm_destroy_building_assassin_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = assassin_castle_01 } remove_building = assassin_castle_01 }
            }
        }
    }
}

DI_tm_building_event_tower_of_silence_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = event_tower_of_silence_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = event_tower_of_silence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = event_tower_of_silence_01
                }
            }
        }
    }
}

DI_tm_destroy_building_event_tower_of_silence_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = event_tower_of_silence_01 } remove_building = event_tower_of_silence_01 }
            }
        }
    }
}

DI_tm_building_church_of_the_theotokos_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = church_of_the_theotokos }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = church_of_the_theotokos
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = church_of_the_theotokos
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = parthenon }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = church_of_the_theotokos
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = parthenon
                }
            }
        }
    }
}

DI_tm_destroy_building_church_of_the_theotokos_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = parthenon } remove_building = parthenon }
                else_if = { limit = { has_building = church_of_the_theotokos } remove_building = church_of_the_theotokos }
            }
        }
    }
}

DI_tm_building_hagios_demetrios_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hagios_demetrios }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hagios_demetrios
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hagios_demetrios
                }
            }
        }
    }
}

DI_tm_destroy_building_hagios_demetrios_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hagios_demetrios } remove_building = hagios_demetrios }
            }
        }
    }
}

DI_tm_building_kassiopi_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kassiopi_castle }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kassiopi_castle
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kassiopi_castle
                }
            }
        }
    }
}

DI_tm_destroy_building_kassiopi_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kassiopi_castle } remove_building = kassiopi_castle }
            }
        }
    }
}

DI_tm_building_saint_lazarus_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = saint_lazarus }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = saint_lazarus
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = saint_lazarus
                }
            }
        }
    }
}

DI_tm_destroy_building_saint_lazarus_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = saint_lazarus } remove_building = saint_lazarus }
            }
        }
    }
}

DI_tm_building_sumela_monastery_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sumela_monastery_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sumela_monastery_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sumela_monastery_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = sumela_monastery_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sumela_monastery_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sumela_monastery_02
                }
            }
        }
    }
}

DI_tm_destroy_building_sumela_monastery_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sumela_monastery_02 } remove_building = sumela_monastery_02 }
                else_if = { limit = { has_building = sumela_monastery_01 } remove_building = sumela_monastery_01 }
            }
        }
    }
}

DI_tm_building_patras_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = patras_castle }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = patras_castle
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = patras_castle
                }
            }
        }
    }
}

DI_tm_destroy_building_patras_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = patras_castle } remove_building = patras_castle }
            }
        }
    }
}

DI_tm_building_maiden_tower_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = maiden_tower }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maiden_tower
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maiden_tower
                }
            }
        }
    }
}

DI_tm_destroy_building_maiden_tower_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = maiden_tower } remove_building = maiden_tower }
            }
        }
    }
}

DI_tm_building_despot_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = despot_palace }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = despot_palace
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = despot_palace
                }
            }
        }
    }
}

DI_tm_destroy_building_despot_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = despot_palace } remove_building = despot_palace }
            }
        }
    }
}

DI_tm_building_meteora_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = meteora_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = meteora_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = meteora_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = meteora_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = meteora_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = meteora_02
                }
            }
        }
    }
}

DI_tm_destroy_building_meteora_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = meteora_02 } remove_building = meteora_02 }
                else_if = { limit = { has_building = meteora_01 } remove_building = meteora_01 }
            }
        }
    }
}

DI_tm_building_mount_athos_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mount_athos_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_athos_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_athos_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = mount_athos_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_athos_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_athos_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = mount_athos_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_athos_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_athos_03
                }
            }
        }
    }
}

DI_tm_destroy_building_mount_athos_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mount_athos_03 } remove_building = mount_athos_03 }
                else_if = { limit = { has_building = mount_athos_02 } remove_building = mount_athos_02 }
                else_if = { limit = { has_building = mount_athos_01 } remove_building = mount_athos_01 }
            }
        }
    }
}

DI_tm_building_apollinare_nuovo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = apollinare_nuovo }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = apollinare_nuovo
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = apollinare_nuovo
                }
            }
        }
    }
}

DI_tm_destroy_building_apollinare_nuovo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = apollinare_nuovo } remove_building = apollinare_nuovo }
            }
        }
    }
}

DI_tm_building_saint_catherine_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = saint_catherine }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = saint_catherine
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = saint_catherine
                }
            }
        }
    }
}

DI_tm_destroy_building_saint_catherine_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = saint_catherine } remove_building = saint_catherine }
            }
        }
    }
}

DI_tm_building_jvari_monastery_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jvari_monastery }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jvari_monastery
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jvari_monastery
                }
            }
        }
    }
}

DI_tm_destroy_building_jvari_monastery_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jvari_monastery } remove_building = jvari_monastery }
            }
        }
    }
}

DI_tm_building_etchmiadzin_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = etchmiadzin_cathedral }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = etchmiadzin_cathedral
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = etchmiadzin_cathedral
                }
            }
        }
    }
}

DI_tm_destroy_building_etchmiadzin_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = etchmiadzin_cathedral } remove_building = etchmiadzin_cathedral }
            }
        }
    }
}

DI_tm_building_cattolica_stilo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = cattolica_stilo }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cattolica_stilo
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cattolica_stilo
                }
            }
        }
    }
}

DI_tm_destroy_building_cattolica_stilo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = cattolica_stilo } remove_building = cattolica_stilo }
            }
        }
    }
}

DI_tm_building_hosios_loukas_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hosios_loukas }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hosios_loukas
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hosios_loukas
                }
            }
        }
    }
}

DI_tm_destroy_building_hosios_loukas_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hosios_loukas } remove_building = hosios_loukas }
            }
        }
    }
}

DI_tm_building_sofia_ohrid_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sofia_ohrid }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sofia_ohrid
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sofia_ohrid
                }
            }
        }
    }
}

DI_tm_destroy_building_sofia_ohrid_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sofia_ohrid } remove_building = sofia_ohrid }
            }
        }
    }
}

DI_tm_building_fairy_chimneys_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = fairy_chimneys }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fairy_chimneys
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fairy_chimneys
                }
            }
        }
    }
}

DI_tm_destroy_building_fairy_chimneys_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = fairy_chimneys } remove_building = fairy_chimneys }
            }
        }
    }
}

DI_tm_building_cilician_gates_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = cilician_gates }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cilician_gates
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cilician_gates
                }
            }
        }
    }
}

DI_tm_destroy_building_cilician_gates_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = cilician_gates } remove_building = cilician_gates }
            }
        }
    }
}

DI_tm_building_pleasure_dome_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pleasure_dome }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pleasure_dome
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pleasure_dome
                }
            }
        }
    }
}

DI_tm_destroy_building_pleasure_dome_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pleasure_dome } remove_building = pleasure_dome }
            }
        }
    }
}

DI_tm_building_burkhan_khaldun_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = burkhan_khaldun_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = burkhan_khaldun_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = burkhan_khaldun_01
                }
            }
        }
    }
}

DI_tm_destroy_building_burkhan_khaldun_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = burkhan_khaldun_01 } remove_building = burkhan_khaldun_01 }
            }
        }
    }
}

DI_tm_building_swahili_port_pemba_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = swahili_port_pemba }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_pemba
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_pemba
                }
            }
        }
    }
}

DI_tm_destroy_building_swahili_port_pemba_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = swahili_port_pemba } remove_building = swahili_port_pemba }
            }
        }
    }
}

DI_tm_building_swahili_port_zanzibar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = swahili_port_zanzibar }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_zanzibar
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_zanzibar
                }
            }
        }
    }
}

DI_tm_destroy_building_swahili_port_zanzibar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = swahili_port_zanzibar } remove_building = swahili_port_zanzibar }
            }
        }
    }
}

DI_tm_building_swahili_port_mombasa_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = swahili_port_mombasa }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_mombasa
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_mombasa
                }
            }
        }
    }
}

DI_tm_destroy_building_swahili_port_mombasa_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = swahili_port_mombasa } remove_building = swahili_port_mombasa }
            }
        }
    }
}

DI_tm_building_swahili_port_pate_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = swahili_port_pate }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_pate
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_pate
                }
            }
        }
    }
}

DI_tm_destroy_building_swahili_port_pate_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = swahili_port_pate } remove_building = swahili_port_pate }
            }
        }
    }
}

DI_tm_building_swahili_port_lamu_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = swahili_port_lamu }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_lamu
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_lamu
                }
            }
        }
    }
}

DI_tm_destroy_building_swahili_port_lamu_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = swahili_port_lamu } remove_building = swahili_port_lamu }
            }
        }
    }
}

DI_tm_building_wulingyuan_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wulingyuan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wulingyuan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wulingyuan_01
                }
            }
        }
    }
}

DI_tm_destroy_building_wulingyuan_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wulingyuan_01 } remove_building = wulingyuan_01 }
            }
        }
    }
}

DI_tm_building_leshan_giant_buddha_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = leshan_giant_buddha_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = leshan_giant_buddha_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = leshan_giant_buddha_01
                }
            }
        }
    }
}

DI_tm_destroy_building_leshan_giant_buddha_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = leshan_giant_buddha_01 } remove_building = leshan_giant_buddha_01 }
            }
        }
    }
}

DI_tm_building_yungang_grottoes_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = yungang_grottoes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yungang_grottoes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yungang_grottoes_01
                }
            }
        }
    }
}

DI_tm_destroy_building_yungang_grottoes_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = yungang_grottoes_01 } remove_building = yungang_grottoes_01 }
            }
        }
    }
}

DI_tm_building_wudang_mountain_temples_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wudang_mountain_temples_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wudang_mountain_temples_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wudang_mountain_temples_01
                }
            }
        }
    }
}

DI_tm_destroy_building_wudang_mountain_temples_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wudang_mountain_temples_01 } remove_building = wudang_mountain_temples_01 }
            }
        }
    }
}

DI_tm_building_shaolin_monastery_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = shaolin_monastery_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shaolin_monastery_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shaolin_monastery_01
                }
            }
        }
    }
}

DI_tm_destroy_building_shaolin_monastery_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = shaolin_monastery_01 } remove_building = shaolin_monastery_01 }
            }
        }
    }
}

DI_tm_building_lingyin_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lingyin_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lingyin_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lingyin_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_lingyin_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lingyin_temple_01 } remove_building = lingyin_temple_01 }
            }
        }
    }
}

DI_tm_building_giant_wild_goose_pagoda_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = giant_wild_goose_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = giant_wild_goose_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = giant_wild_goose_pagoda_01
                }
            }
        }
    }
}

DI_tm_destroy_building_giant_wild_goose_pagoda_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = giant_wild_goose_pagoda_01 } remove_building = giant_wild_goose_pagoda_01 }
            }
        }
    }
}

DI_tm_building_kaifeng_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kaifeng_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaifeng_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaifeng_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_kaifeng_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kaifeng_palace_01 } remove_building = kaifeng_palace_01 }
            }
        }
    }
}

DI_tm_building_forbidden_city_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = forbidden_city_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = forbidden_city_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = forbidden_city_01
                }
            }
        }
    }
}

DI_tm_destroy_building_forbidden_city_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = forbidden_city_01 } remove_building = forbidden_city_01 }
            }
        }
    }
}

DI_tm_building_qianling_mausoleum_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = qianling_mausoleum_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qianling_mausoleum_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qianling_mausoleum_01
                }
            }
        }
    }
}

DI_tm_destroy_building_qianling_mausoleum_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = qianling_mausoleum_01 } remove_building = qianling_mausoleum_01 }
            }
        }
    }
}

DI_tm_building_quanzhou_seaport_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = quanzhou_seaport_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = quanzhou_seaport_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = quanzhou_seaport_01
                }
            }
        }
    }
}

DI_tm_destroy_building_quanzhou_seaport_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = quanzhou_seaport_01 } remove_building = quanzhou_seaport_01 }
            }
        }
    }
}

DI_tm_building_angkor_wat_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = angkor_wat_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = angkor_wat_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = angkor_wat_01
                }
            }
        }
    }
}

DI_tm_destroy_building_angkor_wat_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = angkor_wat_01 } remove_building = angkor_wat_01 }
            }
        }
    }
}

DI_tm_building_citadel_thang_long_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = citadel_thang_long_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_thang_long_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_thang_long_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = citadel_thang_long_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_thang_long_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_thang_long_02
                }
            }
        }
    }
}

DI_tm_destroy_building_citadel_thang_long_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = citadel_thang_long_02 } remove_building = citadel_thang_long_02 }
                else_if = { limit = { has_building = citadel_thang_long_01 } remove_building = citadel_thang_long_01 }
            }
        }
    }
}

DI_tm_building_po_klong_garai_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = po_klong_garai_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = po_klong_garai_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = po_klong_garai_01
                }
            }
        }
    }
}

DI_tm_destroy_building_po_klong_garai_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = po_klong_garai_01 } remove_building = po_klong_garai_01 }
            }
        }
    }
}

DI_tm_building_krakatoa_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = krakatoa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = krakatoa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = krakatoa_01
                }
            }
        }
    }
}

DI_tm_destroy_building_krakatoa_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = krakatoa_01 } remove_building = krakatoa_01 }
            }
        }
    }
}

DI_tm_building_borobudur_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = borobudur_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = borobudur_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = borobudur_01
                }
            }
        }
    }
}

DI_tm_destroy_building_borobudur_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = borobudur_01 } remove_building = borobudur_01 }
            }
        }
    }
}

DI_tm_building_hoshi_ryokan_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hoshi_ryokan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hoshi_ryokan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hoshi_ryokan_01
                }
            }
        }
    }
}

DI_tm_destroy_building_hoshi_ryokan_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hoshi_ryokan_01 } remove_building = hoshi_ryokan_01 }
            }
        }
    }
}

DI_tm_building_herat_bazaar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = herat_bazaar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = herat_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = herat_bazaar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = herat_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = herat_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = herat_bazaar_02
                }
            }
        }
    }
}

DI_tm_destroy_building_herat_bazaar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = herat_bazaar_02 } remove_building = herat_bazaar_02 }
                else_if = { limit = { has_building = herat_bazaar_01 } remove_building = herat_bazaar_01 }
            }
        }
    }
}

DI_tm_building_dvin_shuka_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dvin_shuka_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dvin_shuka_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dvin_shuka_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = dvin_shuka_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dvin_shuka_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dvin_shuka_02
                }
            }
        }
    }
}

DI_tm_destroy_building_dvin_shuka_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dvin_shuka_02 } remove_building = dvin_shuka_02 }
                else_if = { limit = { has_building = dvin_shuka_01 } remove_building = dvin_shuka_01 }
            }
        }
    }
}

DI_tm_building_lhasa_market_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lhasa_market_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lhasa_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lhasa_market_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = lhasa_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lhasa_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lhasa_market_02
                }
            }
        }
    }
}

DI_tm_destroy_building_lhasa_market_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lhasa_market_02 } remove_building = lhasa_market_02 }
                else_if = { limit = { has_building = lhasa_market_01 } remove_building = lhasa_market_01 }
            }
        }
    }
}

DI_tm_building_khiva_bazaar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = khiva_bazaar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khiva_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khiva_bazaar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = khiva_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khiva_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khiva_bazaar_02
                }
            }
        }
    }
}

DI_tm_destroy_building_khiva_bazaar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = khiva_bazaar_02 } remove_building = khiva_bazaar_02 }
                else_if = { limit = { has_building = khiva_bazaar_01 } remove_building = khiva_bazaar_01 }
            }
        }
    }
}

DI_tm_building_changan_market_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = changan_market_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = changan_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = changan_market_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = changan_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = changan_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = changan_market_02
                }
            }
        }
    }
}

DI_tm_destroy_building_changan_market_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = changan_market_02 } remove_building = changan_market_02 }
                else_if = { limit = { has_building = changan_market_01 } remove_building = changan_market_01 }
            }
        }
    }
}

DI_tm_building_lahur_bazaar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lahur_bazaar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lahur_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lahur_bazaar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = lahur_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lahur_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lahur_bazaar_02
                }
            }
        }
    }
}

DI_tm_destroy_building_lahur_bazaar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lahur_bazaar_02 } remove_building = lahur_bazaar_02 }
                else_if = { limit = { has_building = lahur_bazaar_01 } remove_building = lahur_bazaar_01 }
            }
        }
    }
}

DI_tm_building_hamadan_bazaar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hamadan_bazaar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hamadan_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hamadan_bazaar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hamadan_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hamadan_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hamadan_bazaar_02
                }
            }
        }
    }
}

DI_tm_destroy_building_hamadan_bazaar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hamadan_bazaar_02 } remove_building = hamadan_bazaar_02 }
                else_if = { limit = { has_building = hamadan_bazaar_01 } remove_building = hamadan_bazaar_01 }
            }
        }
    }
}

DI_tm_building_dunhuang_market_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dunhuang_market_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dunhuang_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dunhuang_market_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = dunhuang_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dunhuang_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dunhuang_market_02
                }
            }
        }
    }
}

DI_tm_destroy_building_dunhuang_market_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dunhuang_market_02 } remove_building = dunhuang_market_02 }
                else_if = { limit = { has_building = dunhuang_market_01 } remove_building = dunhuang_market_01 }
            }
        }
    }
}

DI_tm_building_sunday_bazaar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sunday_bazaar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sunday_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sunday_bazaar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = sunday_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sunday_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sunday_bazaar_02
                }
            }
        }
    }
}

DI_tm_destroy_building_sunday_bazaar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sunday_bazaar_02 } remove_building = sunday_bazaar_02 }
                else_if = { limit = { has_building = sunday_bazaar_01 } remove_building = sunday_bazaar_01 }
            }
        }
    }
}

DI_tm_building_mount_fuji_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mount_fuji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_fuji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_fuji_01
                }
            }
        }
    }
}

DI_tm_destroy_building_mount_fuji_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mount_fuji_01 } remove_building = mount_fuji_01 }
            }
        }
    }
}

DI_tm_building_itsukushima_jinja_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = itsukushima_jinja_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itsukushima_jinja_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itsukushima_jinja_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = itsukushima_jinja_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itsukushima_jinja_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itsukushima_jinja_02
                }
            }
        }
    }
}

DI_tm_destroy_building_itsukushima_jinja_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = itsukushima_jinja_02 } remove_building = itsukushima_jinja_02 }
                else_if = { limit = { has_building = itsukushima_jinja_01 } remove_building = itsukushima_jinja_01 }
            }
        }
    }
}

DI_tm_building_heian_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = heian_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = heian_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = heian_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_heian_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = heian_palace_01 } remove_building = heian_palace_01 }
            }
        }
    }
}

DI_tm_building_ise_jingu_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ise_jingu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ise_jingu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ise_jingu_01
                }
            }
        }
    }
}

DI_tm_destroy_building_ise_jingu_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ise_jingu_01 } remove_building = ise_jingu_01 }
            }
        }
    }
}

DI_tm_building_kofuku_ji_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kofuku_ji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kofuku_ji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kofuku_ji_01
                }
            }
        }
    }
}

DI_tm_destroy_building_kofuku_ji_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kofuku_ji_01 } remove_building = kofuku_ji_01 }
            }
        }
    }
}

DI_tm_building_enryaku_ji_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = enryaku_ji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = enryaku_ji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = enryaku_ji_01
                }
            }
        }
    }
}

DI_tm_destroy_building_enryaku_ji_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = enryaku_ji_01 } remove_building = enryaku_ji_01 }
            }
        }
    }
}

DI_tm_building_dazaifu_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dazaifu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dazaifu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dazaifu_01
                }
            }
        }
    }
}

DI_tm_destroy_building_dazaifu_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dazaifu_01 } remove_building = dazaifu_01 }
            }
        }
    }
}

DI_tm_building_chinjufu_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = chinjufu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chinjufu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chinjufu_01
                }
            }
        }
    }
}

DI_tm_destroy_building_chinjufu_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = chinjufu_01 } remove_building = chinjufu_01 }
            }
        }
    }
}

DI_tm_building_hakata_port_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hakata_port_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hakata_port_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hakata_port_01
                }
            }
        }
    }
}

DI_tm_destroy_building_hakata_port_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hakata_port_01 } remove_building = hakata_port_01 }
            }
        }
    }
}

DI_tm_building_hwangnyongsa_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hwangnyongsa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hwangnyongsa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hwangnyongsa_01
                }
            }
        }
    }
}

DI_tm_destroy_building_hwangnyongsa_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hwangnyongsa_01 } remove_building = hwangnyongsa_01 }
            }
        }
    }
}

DI_tm_building_byeokran_port_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = byeokran_port_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = byeokran_port_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = byeokran_port_01
                }
            }
        }
    }
}

DI_tm_destroy_building_byeokran_port_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = byeokran_port_01 } remove_building = byeokran_port_01 }
            }
        }
    }
}

DI_tm_building_mount_baekdu_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mount_baekdu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_baekdu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_baekdu_01
                }
            }
        }
    }
}

DI_tm_destroy_building_mount_baekdu_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mount_baekdu_01 } remove_building = mount_baekdu_01 }
            }
        }
    }
}

DI_tm_building_dau_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dau_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dau_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dau_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_dau_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dau_temple_01 } remove_building = dau_temple_01 }
            }
        }
    }
}

DI_tm_building_liuhe_pagoda_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = liuhe_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liuhe_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liuhe_pagoda_01
                }
            }
        }
    }
}

DI_tm_destroy_building_liuhe_pagoda_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = liuhe_pagoda_01 } remove_building = liuhe_pagoda_01 }
            }
        }
    }
}

DI_tm_building_muaro_jambi_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = muaro_jambi_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = muaro_jambi_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = muaro_jambi_01
                }
            }
        }
    }
}

DI_tm_destroy_building_muaro_jambi_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = muaro_jambi_01 } remove_building = muaro_jambi_01 }
            }
        }
    }
}

DI_tm_building_hanging_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hanging_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanging_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanging_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_hanging_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hanging_temple_01 } remove_building = hanging_temple_01 }
            }
        }
    }
}

DI_tm_building_pagoda_of_fogong_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pagoda_of_fogong_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pagoda_of_fogong_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pagoda_of_fogong_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pagoda_of_fogong_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pagoda_of_fogong_temple_01 } remove_building = pagoda_of_fogong_temple_01 }
            }
        }
    }
}

DI_tm_building_plain_of_jars_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = plain_of_jars_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = plain_of_jars_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = plain_of_jars_01
                }
            }
        }
    }
}

DI_tm_destroy_building_plain_of_jars_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = plain_of_jars_01 } remove_building = plain_of_jars_01 }
            }
        }
    }
}

DI_tm_building_dieng_plateau_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dieng_plateau_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dieng_plateau_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dieng_plateau_01
                }
            }
        }
    }
}

DI_tm_destroy_building_dieng_plateau_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dieng_plateau_01 } remove_building = dieng_plateau_01 }
            }
        }
    }
}

DI_tm_building_mount_apo_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mount_apo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_apo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_apo_01
                }
            }
        }
    }
}

DI_tm_destroy_building_mount_apo_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mount_apo_01 } remove_building = mount_apo_01 }
            }
        }
    }
}

DI_tm_building_besakih_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = besakih_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = besakih_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = besakih_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_besakih_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = besakih_temple_01 } remove_building = besakih_temple_01 }
            }
        }
    }
}

DI_tm_building_gongsanseong_fortress_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = gongsanseong_fortress_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = gongsanseong_fortress_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = gongsanseong_fortress_01
                }
            }
        }
    }
}

DI_tm_destroy_building_gongsanseong_fortress_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = gongsanseong_fortress_01 } remove_building = gongsanseong_fortress_01 }
            }
        }
    }
}

DI_tm_building_white_deer_grotto_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = white_deer_grotto_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = white_deer_grotto_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = white_deer_grotto_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_white_deer_grotto_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = white_deer_grotto_academy_01 } remove_building = white_deer_grotto_academy_01 }
            }
        }
    }
}

DI_tm_building_shigu_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = shigu_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shigu_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shigu_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_shigu_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = shigu_academy_01 } remove_building = shigu_academy_01 }
            }
        }
    }
}

DI_tm_building_culai_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = culai_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = culai_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = culai_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_culai_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = culai_academy_01 } remove_building = culai_academy_01 }
            }
        }
    }
}

DI_tm_building_lize_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lize_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lize_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lize_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_lize_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lize_academy_01 } remove_building = lize_academy_01 }
            }
        }
    }
}

DI_tm_building_maoshan_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = maoshan_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maoshan_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maoshan_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_maoshan_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = maoshan_academy_01 } remove_building = maoshan_academy_01 }
            }
        }
    }
}

DI_tm_building_tiantai_monasteries_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tiantai_monasteries_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tiantai_monasteries_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tiantai_monasteries_01
                }
            }
        }
    }
}

DI_tm_destroy_building_tiantai_monasteries_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tiantai_monasteries_01 } remove_building = tiantai_monasteries_01 }
            }
        }
    }
}

DI_tm_building_jizu_shan_temples_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jizu_shan_temples_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jizu_shan_temples_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jizu_shan_temples_01
                }
            }
        }
    }
}

DI_tm_destroy_building_jizu_shan_temples_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jizu_shan_temples_01 } remove_building = jizu_shan_temples_01 }
            }
        }
    }
}

DI_tm_building_nanhua_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = nanhua_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nanhua_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nanhua_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_nanhua_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = nanhua_temple_01 } remove_building = nanhua_temple_01 }
            }
        }
    }
}

DI_tm_building_mozu_tombs_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mozu_tombs }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mozu_tombs
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mozu_tombs
                }
            }
        }
    }
}

DI_tm_destroy_building_mozu_tombs_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mozu_tombs } remove_building = mozu_tombs }
            }
        }
    }
}

DI_tm_building_trosky_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = trosky_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trosky_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trosky_castle_01
                }
            }
        }
    }
}

DI_tm_destroy_building_trosky_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = trosky_castle_01 } remove_building = trosky_castle_01 }
            }
        }
    }
}

DI_tm_building_generic_copper_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = generic_copper_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_copper_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_copper_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = generic_copper_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_copper_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_copper_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = generic_copper_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_copper_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_copper_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = generic_copper_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_copper_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_copper_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_generic_copper_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = generic_copper_mines_04 } remove_building = generic_copper_mines_04 }
                else_if = { limit = { has_building = generic_copper_mines_03 } remove_building = generic_copper_mines_03 }
                else_if = { limit = { has_building = generic_copper_mines_02 } remove_building = generic_copper_mines_02 }
                else_if = { limit = { has_building = generic_copper_mines_01 } remove_building = generic_copper_mines_01 }
            }
        }
    }
}

DI_tm_building_generic_silver_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = generic_silver_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_silver_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_silver_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = generic_silver_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_silver_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_silver_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = generic_silver_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_silver_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_silver_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = generic_silver_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_silver_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_silver_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_generic_silver_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = generic_silver_mines_04 } remove_building = generic_silver_mines_04 }
                else_if = { limit = { has_building = generic_silver_mines_03 } remove_building = generic_silver_mines_03 }
                else_if = { limit = { has_building = generic_silver_mines_02 } remove_building = generic_silver_mines_02 }
                else_if = { limit = { has_building = generic_silver_mines_01 } remove_building = generic_silver_mines_01 }
            }
        }
    }
}

DI_tm_building_generic_gold_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = generic_gold_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_gold_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_gold_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = generic_gold_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_gold_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_gold_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = generic_gold_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_gold_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_gold_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = generic_gold_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_gold_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_gold_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_generic_gold_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = generic_gold_mines_04 } remove_building = generic_gold_mines_04 }
                else_if = { limit = { has_building = generic_gold_mines_03 } remove_building = generic_gold_mines_03 }
                else_if = { limit = { has_building = generic_gold_mines_02 } remove_building = generic_gold_mines_02 }
                else_if = { limit = { has_building = generic_gold_mines_01 } remove_building = generic_gold_mines_01 }
            }
        }
    }
}

DI_tm_building_rammelsberg_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = rammelsberg_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rammelsberg_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rammelsberg_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = rammelsberg_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rammelsberg_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rammelsberg_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = rammelsberg_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rammelsberg_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rammelsberg_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = rammelsberg_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rammelsberg_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rammelsberg_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_rammelsberg_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = rammelsberg_mines_04 } remove_building = rammelsberg_mines_04 }
                else_if = { limit = { has_building = rammelsberg_mines_03 } remove_building = rammelsberg_mines_03 }
                else_if = { limit = { has_building = rammelsberg_mines_02 } remove_building = rammelsberg_mines_02 }
                else_if = { limit = { has_building = rammelsberg_mines_01 } remove_building = rammelsberg_mines_01 }
            }
        }
    }
}

DI_tm_building_kutna_hora_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kutna_hora_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kutna_hora_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kutna_hora_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = kutna_hora_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kutna_hora_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kutna_hora_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = kutna_hora_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kutna_hora_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kutna_hora_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = kutna_hora_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kutna_hora_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kutna_hora_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_kutna_hora_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kutna_hora_mines_04 } remove_building = kutna_hora_mines_04 }
                else_if = { limit = { has_building = kutna_hora_mines_03 } remove_building = kutna_hora_mines_03 }
                else_if = { limit = { has_building = kutna_hora_mines_02 } remove_building = kutna_hora_mines_02 }
                else_if = { limit = { has_building = kutna_hora_mines_01 } remove_building = kutna_hora_mines_01 }
            }
        }
    }
}

DI_tm_building_baofeng_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = baofeng_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = baofeng_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = baofeng_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = baofeng_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = baofeng_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = baofeng_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = baofeng_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = baofeng_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = baofeng_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = baofeng_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = baofeng_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = baofeng_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_baofeng_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = baofeng_mines_04 } remove_building = baofeng_mines_04 }
                else_if = { limit = { has_building = baofeng_mines_03 } remove_building = baofeng_mines_03 }
                else_if = { limit = { has_building = baofeng_mines_02 } remove_building = baofeng_mines_02 }
                else_if = { limit = { has_building = baofeng_mines_01 } remove_building = baofeng_mines_01 }
            }
        }
    }
}

DI_tm_building_kremnica_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kremnica_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kremnica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kremnica_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = kremnica_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kremnica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kremnica_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = kremnica_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kremnica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kremnica_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = kremnica_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kremnica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kremnica_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_kremnica_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kremnica_mines_04 } remove_building = kremnica_mines_04 }
                else_if = { limit = { has_building = kremnica_mines_03 } remove_building = kremnica_mines_03 }
                else_if = { limit = { has_building = kremnica_mines_02 } remove_building = kremnica_mines_02 }
                else_if = { limit = { has_building = kremnica_mines_01 } remove_building = kremnica_mines_01 }
            }
        }
    }
}

DI_tm_building_zijinshan_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = zijinshan_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zijinshan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zijinshan_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = zijinshan_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zijinshan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zijinshan_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = zijinshan_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zijinshan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zijinshan_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = zijinshan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zijinshan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zijinshan_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_zijinshan_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = zijinshan_mines_04 } remove_building = zijinshan_mines_04 }
                else_if = { limit = { has_building = zijinshan_mines_03 } remove_building = zijinshan_mines_03 }
                else_if = { limit = { has_building = zijinshan_mines_02 } remove_building = zijinshan_mines_02 }
                else_if = { limit = { has_building = zijinshan_mines_01 } remove_building = zijinshan_mines_01 }
            }
        }
    }
}

DI_tm_building_jiaodong_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jiaodong_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jiaodong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jiaodong_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = jiaodong_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jiaodong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jiaodong_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = jiaodong_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jiaodong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jiaodong_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = jiaodong_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jiaodong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jiaodong_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_jiaodong_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jiaodong_mines_04 } remove_building = jiaodong_mines_04 }
                else_if = { limit = { has_building = jiaodong_mines_03 } remove_building = jiaodong_mines_03 }
                else_if = { limit = { has_building = jiaodong_mines_02 } remove_building = jiaodong_mines_02 }
                else_if = { limit = { has_building = jiaodong_mines_01 } remove_building = jiaodong_mines_01 }
            }
        }
    }
}

DI_tm_building_falun_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = falun_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falun_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falun_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = falun_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falun_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falun_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = falun_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falun_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falun_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = falun_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falun_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falun_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_falun_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = falun_mines_04 } remove_building = falun_mines_04 }
                else_if = { limit = { has_building = falun_mines_03 } remove_building = falun_mines_03 }
                else_if = { limit = { has_building = falun_mines_02 } remove_building = falun_mines_02 }
                else_if = { limit = { has_building = falun_mines_01 } remove_building = falun_mines_01 }
            }
        }
    }
}

DI_tm_building_schwaz_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = schwaz_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = schwaz_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = schwaz_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = schwaz_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = schwaz_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = schwaz_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = schwaz_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = schwaz_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = schwaz_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = schwaz_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = schwaz_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = schwaz_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_schwaz_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = schwaz_mines_04 } remove_building = schwaz_mines_04 }
                else_if = { limit = { has_building = schwaz_mines_03 } remove_building = schwaz_mines_03 }
                else_if = { limit = { has_building = schwaz_mines_02 } remove_building = schwaz_mines_02 }
                else_if = { limit = { has_building = schwaz_mines_01 } remove_building = schwaz_mines_01 }
            }
        }
    }
}

DI_tm_building_liangzhe_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = liangzhe_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liangzhe_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liangzhe_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = liangzhe_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liangzhe_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liangzhe_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = liangzhe_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liangzhe_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liangzhe_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = liangzhe_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liangzhe_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liangzhe_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_liangzhe_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = liangzhe_mines_04 } remove_building = liangzhe_mines_04 }
                else_if = { limit = { has_building = liangzhe_mines_03 } remove_building = liangzhe_mines_03 }
                else_if = { limit = { has_building = liangzhe_mines_02 } remove_building = liangzhe_mines_02 }
                else_if = { limit = { has_building = liangzhe_mines_01 } remove_building = liangzhe_mines_01 }
            }
        }
    }
}

DI_tm_building_argentiera_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = argentiera_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = argentiera_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = argentiera_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = argentiera_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = argentiera_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = argentiera_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = argentiera_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = argentiera_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = argentiera_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = argentiera_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = argentiera_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = argentiera_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_argentiera_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = argentiera_mines_04 } remove_building = argentiera_mines_04 }
                else_if = { limit = { has_building = argentiera_mines_03 } remove_building = argentiera_mines_03 }
                else_if = { limit = { has_building = argentiera_mines_02 } remove_building = argentiera_mines_02 }
                else_if = { limit = { has_building = argentiera_mines_01 } remove_building = argentiera_mines_01 }
            }
        }
    }
}

DI_tm_building_kollur_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kollur_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kollur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kollur_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = kollur_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kollur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kollur_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = kollur_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kollur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kollur_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = kollur_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kollur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kollur_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_kollur_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kollur_mines_04 } remove_building = kollur_mines_04 }
                else_if = { limit = { has_building = kollur_mines_03 } remove_building = kollur_mines_03 }
                else_if = { limit = { has_building = kollur_mines_02 } remove_building = kollur_mines_02 }
                else_if = { limit = { has_building = kollur_mines_01 } remove_building = kollur_mines_01 }
            }
        }
    }
}

DI_tm_building_siderokausia_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = siderokausia_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siderokausia_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siderokausia_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = siderokausia_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siderokausia_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siderokausia_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = siderokausia_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siderokausia_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siderokausia_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = siderokausia_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siderokausia_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siderokausia_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_siderokausia_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = siderokausia_mines_04 } remove_building = siderokausia_mines_04 }
                else_if = { limit = { has_building = siderokausia_mines_03 } remove_building = siderokausia_mines_03 }
                else_if = { limit = { has_building = siderokausia_mines_02 } remove_building = siderokausia_mines_02 }
                else_if = { limit = { has_building = siderokausia_mines_01 } remove_building = siderokausia_mines_01 }
            }
        }
    }
}

DI_tm_building_mali_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mali_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mali_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mali_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = mali_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mali_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mali_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = mali_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mali_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mali_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = mali_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mali_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mali_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_mali_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mali_mines_04 } remove_building = mali_mines_04 }
                else_if = { limit = { has_building = mali_mines_03 } remove_building = mali_mines_03 }
                else_if = { limit = { has_building = mali_mines_02 } remove_building = mali_mines_02 }
                else_if = { limit = { has_building = mali_mines_01 } remove_building = mali_mines_01 }
            }
        }
    }
}

DI_tm_building_konasamudram_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = konasamudram_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konasamudram_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konasamudram_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = konasamudram_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konasamudram_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konasamudram_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = konasamudram_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konasamudram_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konasamudram_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = konasamudram_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konasamudram_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konasamudram_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_konasamudram_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = konasamudram_mines_04 } remove_building = konasamudram_mines_04 }
                else_if = { limit = { has_building = konasamudram_mines_03 } remove_building = konasamudram_mines_03 }
                else_if = { limit = { has_building = konasamudram_mines_02 } remove_building = konasamudram_mines_02 }
                else_if = { limit = { has_building = konasamudram_mines_01 } remove_building = konasamudram_mines_01 }
            }
        }
    }
}

DI_tm_building_dean_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dean_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dean_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dean_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = dean_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dean_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dean_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = dean_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dean_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dean_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = dean_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dean_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dean_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_dean_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dean_mines_04 } remove_building = dean_mines_04 }
                else_if = { limit = { has_building = dean_mines_03 } remove_building = dean_mines_03 }
                else_if = { limit = { has_building = dean_mines_02 } remove_building = dean_mines_02 }
                else_if = { limit = { has_building = dean_mines_01 } remove_building = dean_mines_01 }
            }
        }
    }
}

DI_tm_building_phnom_dek_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = phnom_dek_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phnom_dek_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phnom_dek_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = phnom_dek_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phnom_dek_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phnom_dek_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = phnom_dek_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phnom_dek_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phnom_dek_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = phnom_dek_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phnom_dek_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phnom_dek_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_phnom_dek_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = phnom_dek_mines_04 } remove_building = phnom_dek_mines_04 }
                else_if = { limit = { has_building = phnom_dek_mines_03 } remove_building = phnom_dek_mines_03 }
                else_if = { limit = { has_building = phnom_dek_mines_02 } remove_building = phnom_dek_mines_02 }
                else_if = { limit = { has_building = phnom_dek_mines_01 } remove_building = phnom_dek_mines_01 }
            }
        }
    }
}

DI_tm_building_hanxing_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hanxing_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanxing_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanxing_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hanxing_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanxing_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanxing_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hanxing_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanxing_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanxing_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hanxing_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanxing_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanxing_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_hanxing_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hanxing_mines_04 } remove_building = hanxing_mines_04 }
                else_if = { limit = { has_building = hanxing_mines_03 } remove_building = hanxing_mines_03 }
                else_if = { limit = { has_building = hanxing_mines_02 } remove_building = hanxing_mines_02 }
                else_if = { limit = { has_building = hanxing_mines_01 } remove_building = hanxing_mines_01 }
            }
        }
    }
}

DI_tm_building_chihu_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = chihu_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chihu_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chihu_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = chihu_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chihu_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chihu_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = chihu_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chihu_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chihu_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = chihu_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chihu_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chihu_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_chihu_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = chihu_mines_04 } remove_building = chihu_mines_04 }
                else_if = { limit = { has_building = chihu_mines_03 } remove_building = chihu_mines_03 }
                else_if = { limit = { has_building = chihu_mines_02 } remove_building = chihu_mines_02 }
                else_if = { limit = { has_building = chihu_mines_01 } remove_building = chihu_mines_01 }
            }
        }
    }
}

DI_tm_building_zawar_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = zawar_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zawar_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zawar_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = zawar_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zawar_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zawar_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = zawar_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zawar_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zawar_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = zawar_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zawar_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zawar_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_zawar_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = zawar_mines_04 } remove_building = zawar_mines_04 }
                else_if = { limit = { has_building = zawar_mines_03 } remove_building = zawar_mines_03 }
                else_if = { limit = { has_building = zawar_mines_02 } remove_building = zawar_mines_02 }
                else_if = { limit = { has_building = zawar_mines_01 } remove_building = zawar_mines_01 }
            }
        }
    }
}

DI_tm_building_takkeda_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = takkeda_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = takkeda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = takkeda_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = takkeda_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = takkeda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = takkeda_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = takkeda_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = takkeda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = takkeda_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = takkeda_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = takkeda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = takkeda_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_takkeda_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = takkeda_mines_04 } remove_building = takkeda_mines_04 }
                else_if = { limit = { has_building = takkeda_mines_03 } remove_building = takkeda_mines_03 }
                else_if = { limit = { has_building = takkeda_mines_02 } remove_building = takkeda_mines_02 }
                else_if = { limit = { has_building = takkeda_mines_01 } remove_building = takkeda_mines_01 }
            }
        }
    }
}

DI_tm_building_khetri_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = khetri_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khetri_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khetri_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = khetri_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khetri_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khetri_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = khetri_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khetri_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khetri_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = khetri_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khetri_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khetri_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_khetri_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = khetri_mines_04 } remove_building = khetri_mines_04 }
                else_if = { limit = { has_building = khetri_mines_03 } remove_building = khetri_mines_03 }
                else_if = { limit = { has_building = khetri_mines_02 } remove_building = khetri_mines_02 }
                else_if = { limit = { has_building = khetri_mines_01 } remove_building = khetri_mines_01 }
            }
        }
    }
}

DI_tm_building_taghaza_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = taghaza_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = taghaza_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = taghaza_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = taghaza_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = taghaza_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = taghaza_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = taghaza_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = taghaza_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = taghaza_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = taghaza_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = taghaza_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = taghaza_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_taghaza_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = taghaza_mines_04 } remove_building = taghaza_mines_04 }
                else_if = { limit = { has_building = taghaza_mines_03 } remove_building = taghaza_mines_03 }
                else_if = { limit = { has_building = taghaza_mines_02 } remove_building = taghaza_mines_02 }
                else_if = { limit = { has_building = taghaza_mines_01 } remove_building = taghaza_mines_01 }
            }
        }
    }
}

DI_tm_building_ijil_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ijil_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ijil_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ijil_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = ijil_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ijil_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ijil_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = ijil_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ijil_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ijil_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = ijil_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ijil_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ijil_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_ijil_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ijil_mines_04 } remove_building = ijil_mines_04 }
                else_if = { limit = { has_building = ijil_mines_03 } remove_building = ijil_mines_03 }
                else_if = { limit = { has_building = ijil_mines_02 } remove_building = ijil_mines_02 }
                else_if = { limit = { has_building = ijil_mines_01 } remove_building = ijil_mines_01 }
            }
        }
    }
}

DI_tm_building_turda_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = turda_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = turda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = turda_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = turda_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = turda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = turda_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = turda_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = turda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = turda_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = turda_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = turda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = turda_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_turda_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = turda_mines_04 } remove_building = turda_mines_04 }
                else_if = { limit = { has_building = turda_mines_03 } remove_building = turda_mines_03 }
                else_if = { limit = { has_building = turda_mines_02 } remove_building = turda_mines_02 }
                else_if = { limit = { has_building = turda_mines_01 } remove_building = turda_mines_01 }
            }
        }
    }
}

DI_tm_building_zigong_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = zigong_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zigong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zigong_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = zigong_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zigong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zigong_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = zigong_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zigong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zigong_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = zigong_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zigong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zigong_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_zigong_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = zigong_mines_04 } remove_building = zigong_mines_04 }
                else_if = { limit = { has_building = zigong_mines_03 } remove_building = zigong_mines_03 }
                else_if = { limit = { has_building = zigong_mines_02 } remove_building = zigong_mines_02 }
                else_if = { limit = { has_building = zigong_mines_01 } remove_building = zigong_mines_01 }
            }
        }
    }
}

DI_tm_building_phocaea_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = phocaea_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phocaea_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phocaea_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = phocaea_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phocaea_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phocaea_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = phocaea_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phocaea_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phocaea_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = phocaea_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phocaea_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phocaea_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_phocaea_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = phocaea_mines_04 } remove_building = phocaea_mines_04 }
                else_if = { limit = { has_building = phocaea_mines_03 } remove_building = phocaea_mines_03 }
                else_if = { limit = { has_building = phocaea_mines_02 } remove_building = phocaea_mines_02 }
                else_if = { limit = { has_building = phocaea_mines_01 } remove_building = phocaea_mines_01 }
            }
        }
    }
}

DI_tm_building_pansjhir_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pansjhir_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pansjhir_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pansjhir_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = pansjhir_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pansjhir_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pansjhir_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = pansjhir_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pansjhir_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pansjhir_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = pansjhir_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pansjhir_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pansjhir_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_pansjhir_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pansjhir_mines_04 } remove_building = pansjhir_mines_04 }
                else_if = { limit = { has_building = pansjhir_mines_03 } remove_building = pansjhir_mines_03 }
                else_if = { limit = { has_building = pansjhir_mines_02 } remove_building = pansjhir_mines_02 }
                else_if = { limit = { has_building = pansjhir_mines_01 } remove_building = pansjhir_mines_01 }
            }
        }
    }
}

DI_tm_building_trepca_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = trepca_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trepca_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trepca_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = trepca_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trepca_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trepca_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = trepca_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trepca_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trepca_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = trepca_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trepca_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trepca_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_trepca_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = trepca_mines_04 } remove_building = trepca_mines_04 }
                else_if = { limit = { has_building = trepca_mines_03 } remove_building = trepca_mines_03 }
                else_if = { limit = { has_building = trepca_mines_02 } remove_building = trepca_mines_02 }
                else_if = { limit = { has_building = trepca_mines_01 } remove_building = trepca_mines_01 }
            }
        }
    }
}

DI_tm_building_rudnik_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = rudnik_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rudnik_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rudnik_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = rudnik_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rudnik_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rudnik_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = rudnik_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rudnik_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rudnik_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = rudnik_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rudnik_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rudnik_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_rudnik_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = rudnik_mines_04 } remove_building = rudnik_mines_04 }
                else_if = { limit = { has_building = rudnik_mines_03 } remove_building = rudnik_mines_03 }
                else_if = { limit = { has_building = rudnik_mines_02 } remove_building = rudnik_mines_02 }
                else_if = { limit = { has_building = rudnik_mines_01 } remove_building = rudnik_mines_01 }
            }
        }
    }
}

DI_tm_building_cevennes_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = cevennes_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cevennes_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cevennes_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = cevennes_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cevennes_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cevennes_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = cevennes_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cevennes_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cevennes_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = cevennes_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cevennes_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cevennes_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_cevennes_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = cevennes_mines_04 } remove_building = cevennes_mines_04 }
                else_if = { limit = { has_building = cevennes_mines_03 } remove_building = cevennes_mines_03 }
                else_if = { limit = { has_building = cevennes_mines_02 } remove_building = cevennes_mines_02 }
                else_if = { limit = { has_building = cevennes_mines_01 } remove_building = cevennes_mines_01 }
            }
        }
    }
}

DI_tm_building_guiyang_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = guiyang_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = guiyang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = guiyang_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = guiyang_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = guiyang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = guiyang_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = guiyang_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = guiyang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = guiyang_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = guiyang_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = guiyang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = guiyang_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_guiyang_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = guiyang_mines_04 } remove_building = guiyang_mines_04 }
                else_if = { limit = { has_building = guiyang_mines_03 } remove_building = guiyang_mines_03 }
                else_if = { limit = { has_building = guiyang_mines_02 } remove_building = guiyang_mines_02 }
                else_if = { limit = { has_building = guiyang_mines_01 } remove_building = guiyang_mines_01 }
            }
        }
    }
}

DI_tm_building_kaibao_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kaibao_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaibao_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaibao_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = kaibao_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaibao_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaibao_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = kaibao_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaibao_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaibao_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = kaibao_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaibao_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaibao_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_kaibao_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kaibao_mines_04 } remove_building = kaibao_mines_04 }
                else_if = { limit = { has_building = kaibao_mines_03 } remove_building = kaibao_mines_03 }
                else_if = { limit = { has_building = kaibao_mines_02 } remove_building = kaibao_mines_02 }
                else_if = { limit = { has_building = kaibao_mines_01 } remove_building = kaibao_mines_01 }
            }
        }
    }
}

DI_tm_building_hetian_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hetian_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hetian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hetian_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hetian_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hetian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hetian_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hetian_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hetian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hetian_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hetian_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hetian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hetian_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_hetian_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hetian_mines_04 } remove_building = hetian_mines_04 }
                else_if = { limit = { has_building = hetian_mines_03 } remove_building = hetian_mines_03 }
                else_if = { limit = { has_building = hetian_mines_02 } remove_building = hetian_mines_02 }
                else_if = { limit = { has_building = hetian_mines_01 } remove_building = hetian_mines_01 }
            }
        }
    }
}

DI_tm_building_dushan_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dushan_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dushan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dushan_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = dushan_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dushan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dushan_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = dushan_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dushan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dushan_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = dushan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dushan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dushan_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_dushan_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dushan_mines_04 } remove_building = dushan_mines_04 }
                else_if = { limit = { has_building = dushan_mines_03 } remove_building = dushan_mines_03 }
                else_if = { limit = { has_building = dushan_mines_02 } remove_building = dushan_mines_02 }
                else_if = { limit = { has_building = dushan_mines_01 } remove_building = dushan_mines_01 }
            }
        }
    }
}

DI_tm_building_xiuyan_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = xiuyan_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = xiuyan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = xiuyan_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = xiuyan_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = xiuyan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = xiuyan_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = xiuyan_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = xiuyan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = xiuyan_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = xiuyan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = xiuyan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = xiuyan_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_xiuyan_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = xiuyan_mines_04 } remove_building = xiuyan_mines_04 }
                else_if = { limit = { has_building = xiuyan_mines_03 } remove_building = xiuyan_mines_03 }
                else_if = { limit = { has_building = xiuyan_mines_02 } remove_building = xiuyan_mines_02 }
                else_if = { limit = { has_building = xiuyan_mines_01 } remove_building = xiuyan_mines_01 }
            }
        }
    }
}

DI_tm_building_itoigawa_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = itoigawa_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itoigawa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itoigawa_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = itoigawa_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itoigawa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itoigawa_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = itoigawa_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itoigawa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itoigawa_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = itoigawa_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itoigawa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itoigawa_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_itoigawa_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = itoigawa_mines_04 } remove_building = itoigawa_mines_04 }
                else_if = { limit = { has_building = itoigawa_mines_03 } remove_building = itoigawa_mines_03 }
                else_if = { limit = { has_building = itoigawa_mines_02 } remove_building = itoigawa_mines_02 }
                else_if = { limit = { has_building = itoigawa_mines_01 } remove_building = itoigawa_mines_01 }
            }
        }
    }
}

DI_tm_building_lantian_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = lantian_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lantian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lantian_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = lantian_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lantian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lantian_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = lantian_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lantian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lantian_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = lantian_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lantian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lantian_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_lantian_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = lantian_mines_04 } remove_building = lantian_mines_04 }
                else_if = { limit = { has_building = lantian_mines_03 } remove_building = lantian_mines_03 }
                else_if = { limit = { has_building = lantian_mines_02 } remove_building = lantian_mines_02 }
                else_if = { limit = { has_building = lantian_mines_01 } remove_building = lantian_mines_01 }
            }
        }
    }
}

DI_tm_building_fengtian_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = fengtian_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fengtian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fengtian_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = fengtian_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fengtian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fengtian_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = fengtian_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fengtian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fengtian_mines_03
                }
            }
        }
    }
}

DI_tm_destroy_building_fengtian_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = fengtian_mines_03 } remove_building = fengtian_mines_03 }
                else_if = { limit = { has_building = fengtian_mines_02 } remove_building = fengtian_mines_02 }
                else_if = { limit = { has_building = fengtian_mines_01 } remove_building = fengtian_mines_01 }
            }
        }
    }
}

DI_tm_building_hpakant_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hpakant_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hpakant_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hpakant_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hpakant_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hpakant_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hpakant_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hpakant_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hpakant_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hpakant_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hpakant_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hpakant_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hpakant_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_hpakant_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = hpakant_mines_04 } remove_building = hpakant_mines_04 }
                else_if = { limit = { has_building = hpakant_mines_03 } remove_building = hpakant_mines_03 }
                else_if = { limit = { has_building = hpakant_mines_02 } remove_building = hpakant_mines_02 }
                else_if = { limit = { has_building = hpakant_mines_01 } remove_building = hpakant_mines_01 }
            }
        }
    }
}

DI_tm_building_allaq_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = allaq_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = allaq_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = allaq_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = allaq_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = allaq_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = allaq_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = allaq_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = allaq_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = allaq_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = allaq_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = allaq_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = allaq_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_allaq_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = allaq_mines_04 } remove_building = allaq_mines_04 }
                else_if = { limit = { has_building = allaq_mines_03 } remove_building = allaq_mines_03 }
                else_if = { limit = { has_building = allaq_mines_02 } remove_building = allaq_mines_02 }
                else_if = { limit = { has_building = allaq_mines_01 } remove_building = allaq_mines_01 }
            }
        }
    }
}

DI_tm_building_verespatak_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = verespatak_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = verespatak_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = verespatak_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = verespatak_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = verespatak_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = verespatak_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = verespatak_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = verespatak_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = verespatak_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = verespatak_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = verespatak_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = verespatak_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_verespatak_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = verespatak_mines_04 } remove_building = verespatak_mines_04 }
                else_if = { limit = { has_building = verespatak_mines_03 } remove_building = verespatak_mines_03 }
                else_if = { limit = { has_building = verespatak_mines_02 } remove_building = verespatak_mines_02 }
                else_if = { limit = { has_building = verespatak_mines_01 } remove_building = verespatak_mines_01 }
            }
        }
    }
}

DI_tm_building_suvarnadvipa_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = suvarnadvipa_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suvarnadvipa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suvarnadvipa_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = suvarnadvipa_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suvarnadvipa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suvarnadvipa_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = suvarnadvipa_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suvarnadvipa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suvarnadvipa_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = suvarnadvipa_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suvarnadvipa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suvarnadvipa_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_suvarnadvipa_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = suvarnadvipa_mines_04 } remove_building = suvarnadvipa_mines_04 }
                else_if = { limit = { has_building = suvarnadvipa_mines_03 } remove_building = suvarnadvipa_mines_03 }
                else_if = { limit = { has_building = suvarnadvipa_mines_02 } remove_building = suvarnadvipa_mines_02 }
                else_if = { limit = { has_building = suvarnadvipa_mines_01 } remove_building = suvarnadvipa_mines_01 }
            }
        }
    }
}

DI_tm_building_nishapur_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = nishapur_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nishapur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nishapur_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = nishapur_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nishapur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nishapur_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = nishapur_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nishapur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nishapur_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = nishapur_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nishapur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nishapur_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_nishapur_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = nishapur_mines_04 } remove_building = nishapur_mines_04 }
                else_if = { limit = { has_building = nishapur_mines_03 } remove_building = nishapur_mines_03 }
                else_if = { limit = { has_building = nishapur_mines_02 } remove_building = nishapur_mines_02 }
                else_if = { limit = { has_building = nishapur_mines_01 } remove_building = nishapur_mines_01 }
            }
        }
    }
}

DI_tm_building_srebrenica_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = srebrenica_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = srebrenica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = srebrenica_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = srebrenica_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = srebrenica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = srebrenica_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = srebrenica_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = srebrenica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = srebrenica_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = srebrenica_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = srebrenica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = srebrenica_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_srebrenica_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = srebrenica_mines_04 } remove_building = srebrenica_mines_04 }
                else_if = { limit = { has_building = srebrenica_mines_03 } remove_building = srebrenica_mines_03 }
                else_if = { limit = { has_building = srebrenica_mines_02 } remove_building = srebrenica_mines_02 }
                else_if = { limit = { has_building = srebrenica_mines_01 } remove_building = srebrenica_mines_01 }
            }
        }
    }
}

DI_tm_building_ratnapura_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ratnapura_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ratnapura_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ratnapura_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = ratnapura_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ratnapura_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ratnapura_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = ratnapura_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ratnapura_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ratnapura_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = ratnapura_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ratnapura_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ratnapura_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_ratnapura_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ratnapura_mines_04 } remove_building = ratnapura_mines_04 }
                else_if = { limit = { has_building = ratnapura_mines_03 } remove_building = ratnapura_mines_03 }
                else_if = { limit = { has_building = ratnapura_mines_02 } remove_building = ratnapura_mines_02 }
                else_if = { limit = { has_building = ratnapura_mines_01 } remove_building = ratnapura_mines_01 }
            }
        }
    }
}

DI_tm_building_sar_i_sang_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sar_i_sang_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sar_i_sang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sar_i_sang_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = sar_i_sang_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sar_i_sang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sar_i_sang_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = sar_i_sang_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sar_i_sang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sar_i_sang_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = sar_i_sang_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sar_i_sang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sar_i_sang_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_sar_i_sang_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sar_i_sang_mines_04 } remove_building = sar_i_sang_mines_04 }
                else_if = { limit = { has_building = sar_i_sang_mines_03 } remove_building = sar_i_sang_mines_03 }
                else_if = { limit = { has_building = sar_i_sang_mines_02 } remove_building = sar_i_sang_mines_02 }
                else_if = { limit = { has_building = sar_i_sang_mines_01 } remove_building = sar_i_sang_mines_01 }
            }
        }
    }
}

DI_tm_building_mogok_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mogok_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mogok_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mogok_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = mogok_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mogok_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mogok_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = mogok_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mogok_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mogok_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = mogok_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mogok_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mogok_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_mogok_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mogok_mines_04 } remove_building = mogok_mines_04 }
                else_if = { limit = { has_building = mogok_mines_03 } remove_building = mogok_mines_03 }
                else_if = { limit = { has_building = mogok_mines_02 } remove_building = mogok_mines_02 }
                else_if = { limit = { has_building = mogok_mines_01 } remove_building = mogok_mines_01 }
            }
        }
    }
}

DI_tm_building_koganeyama_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = koganeyama_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = koganeyama_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = koganeyama_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = koganeyama_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = koganeyama_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = koganeyama_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = koganeyama_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = koganeyama_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = koganeyama_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = koganeyama_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = koganeyama_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = koganeyama_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_koganeyama_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = koganeyama_mines_04 } remove_building = koganeyama_mines_04 }
                else_if = { limit = { has_building = koganeyama_mines_03 } remove_building = koganeyama_mines_03 }
                else_if = { limit = { has_building = koganeyama_mines_02 } remove_building = koganeyama_mines_02 }
                else_if = { limit = { has_building = koganeyama_mines_01 } remove_building = koganeyama_mines_01 }
            }
        }
    }
}

DI_tm_building_tsushima_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tsushima_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tsushima_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tsushima_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = tsushima_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tsushima_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tsushima_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = tsushima_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tsushima_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tsushima_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = tsushima_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tsushima_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tsushima_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_tsushima_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tsushima_mines_04 } remove_building = tsushima_mines_04 }
                else_if = { limit = { has_building = tsushima_mines_03 } remove_building = tsushima_mines_03 }
                else_if = { limit = { has_building = tsushima_mines_02 } remove_building = tsushima_mines_02 }
                else_if = { limit = { has_building = tsushima_mines_01 } remove_building = tsushima_mines_01 }
            }
        }
    }
}

DI_tm_building_sado_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sado_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sado_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sado_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = sado_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sado_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sado_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = sado_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sado_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sado_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = sado_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sado_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sado_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_sado_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sado_mines_04 } remove_building = sado_mines_04 }
                else_if = { limit = { has_building = sado_mines_03 } remove_building = sado_mines_03 }
                else_if = { limit = { has_building = sado_mines_02 } remove_building = sado_mines_02 }
                else_if = { limit = { has_building = sado_mines_01 } remove_building = sado_mines_01 }
            }
        }
    }
}

DI_tm_building_tada_mines_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tada_mines_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tada_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tada_mines_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = tada_mines_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tada_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tada_mines_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = tada_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tada_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tada_mines_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = tada_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tada_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tada_mines_04
                }
            }
        }
    }
}

DI_tm_destroy_building_tada_mines_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tada_mines_04 } remove_building = tada_mines_04 }
                else_if = { limit = { has_building = tada_mines_03 } remove_building = tada_mines_03 }
                else_if = { limit = { has_building = tada_mines_02 } remove_building = tada_mines_02 }
                else_if = { limit = { has_building = tada_mines_01 } remove_building = tada_mines_01 }
            }
        }
    }
}

DI_tm_building_caravanserai_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = caravanserai_01 }
                    }
                    add_building = caravanserai_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = caravanserai_02 }
                    }
                    add_building = caravanserai_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = caravanserai_03 }
                    }
                    add_building = caravanserai_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = caravanserai_04 }
                    }
                    add_building = caravanserai_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = caravanserai_05 }
                    }
                    add_building = caravanserai_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = caravanserai_06 }
                    }
                    add_building = caravanserai_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = caravanserai_07 }
                    }
                    add_building = caravanserai_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = caravanserai_08 }
                    }
                    add_building = caravanserai_08
                }
            }
        }
    }
}

DI_tm_destroy_building_caravanserai_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = caravanserai }
            }
        }
    }
}

DI_tm_building_watermills_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = watermills_01 }
                    }
                    add_building = watermills_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = watermills_02 }
                    }
                    add_building = watermills_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = watermills_03 }
                    }
                    add_building = watermills_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = watermills_04 }
                    }
                    add_building = watermills_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = watermills_05 }
                    }
                    add_building = watermills_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = watermills_06 }
                    }
                    add_building = watermills_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = watermills_07 }
                    }
                    add_building = watermills_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = watermills_08 }
                    }
                    add_building = watermills_08
                }
            }
        }
    }
}

DI_tm_destroy_building_watermills_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = watermills }
            }
        }
    }
}

DI_tm_building_windmills_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = windmills_01 }
                    }
                    add_building = windmills_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = windmills_02 }
                    }
                    add_building = windmills_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = windmills_03 }
                    }
                    add_building = windmills_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = windmills_04 }
                    }
                    add_building = windmills_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = windmills_05 }
                    }
                    add_building = windmills_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = windmills_06 }
                    }
                    add_building = windmills_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = windmills_07 }
                    }
                    add_building = windmills_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = windmills_08 }
                    }
                    add_building = windmills_08
                }
            }
        }
    }
}

DI_tm_destroy_building_windmills_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = windmills }
            }
        }
    }
}

DI_tm_building_qanats_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = qanats_01 }
                    }
                    add_building = qanats_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = qanats_02 }
                    }
                    add_building = qanats_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = qanats_03 }
                    }
                    add_building = qanats_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = qanats_04 }
                    }
                    add_building = qanats_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = qanats_05 }
                    }
                    add_building = qanats_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = qanats_06 }
                    }
                    add_building = qanats_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = qanats_07 }
                    }
                    add_building = qanats_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = qanats_08 }
                    }
                    add_building = qanats_08
                }
            }
        }
    }
}

DI_tm_destroy_building_qanats_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = qanats }
            }
        }
    }
}

DI_tm_building_murex_farm_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = murex_farm_01 }
                    }
                    add_building = murex_farm_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = murex_farm_02 }
                    }
                    add_building = murex_farm_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = murex_farm_03 }
                    }
                    add_building = murex_farm_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = murex_farm_04 }
                    }
                    add_building = murex_farm_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = murex_farm_05 }
                    }
                    add_building = murex_farm_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = murex_farm_06 }
                    }
                    add_building = murex_farm_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = murex_farm_07 }
                    }
                    add_building = murex_farm_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = murex_farm_08 }
                    }
                    add_building = murex_farm_08
                }
            }
        }
    }
}

DI_tm_destroy_building_murex_farm_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = murex_farm }
            }
        }
    }
}

DI_tm_building_paddy_fields_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = paddy_fields_01 }
                    }
                    add_building = paddy_fields_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = paddy_fields_02 }
                    }
                    add_building = paddy_fields_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = paddy_fields_03 }
                    }
                    add_building = paddy_fields_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = paddy_fields_04 }
                    }
                    add_building = paddy_fields_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = paddy_fields_05 }
                    }
                    add_building = paddy_fields_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = paddy_fields_06 }
                    }
                    add_building = paddy_fields_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = paddy_fields_07 }
                    }
                    add_building = paddy_fields_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = paddy_fields_08 }
                    }
                    add_building = paddy_fields_08
                }
            }
        }
    }
}

DI_tm_destroy_building_paddy_fields_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = paddy_fields }
            }
        }
    }
}

DI_tm_building_spice_plantation_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = spice_plantation_01 }
                    }
                    add_building = spice_plantation_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = spice_plantation_02 }
                    }
                    add_building = spice_plantation_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = spice_plantation_03 }
                    }
                    add_building = spice_plantation_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = spice_plantation_04 }
                    }
                    add_building = spice_plantation_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = spice_plantation_05 }
                    }
                    add_building = spice_plantation_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = spice_plantation_06 }
                    }
                    add_building = spice_plantation_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = spice_plantation_07 }
                    }
                    add_building = spice_plantation_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = spice_plantation_08 }
                    }
                    add_building = spice_plantation_08
                }
            }
        }
    }
}

DI_tm_destroy_building_spice_plantation_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = spice_plantation }
            }
        }
    }
}

DI_tm_building_waterworks_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = waterworks_01 }
                    }
                    add_building = waterworks_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = waterworks_02 }
                    }
                    add_building = waterworks_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = waterworks_03 }
                    }
                    add_building = waterworks_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = waterworks_04 }
                    }
                    add_building = waterworks_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = waterworks_05 }
                    }
                    add_building = waterworks_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = waterworks_06 }
                    }
                    add_building = waterworks_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = waterworks_07 }
                    }
                    add_building = waterworks_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = waterworks_08 }
                    }
                    add_building = waterworks_08
                }
            }
        }
    }
}

DI_tm_destroy_building_waterworks_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = waterworks }
            }
        }
    }
}

DI_tm_building_common_tradeport_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = common_tradeport_01 }
                    }
                    add_building = common_tradeport_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = common_tradeport_02 }
                    }
                    add_building = common_tradeport_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = common_tradeport_03 }
                    }
                    add_building = common_tradeport_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = common_tradeport_04 }
                    }
                    add_building = common_tradeport_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = common_tradeport_05 }
                    }
                    add_building = common_tradeport_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = common_tradeport_06 }
                    }
                    add_building = common_tradeport_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = common_tradeport_07 }
                    }
                    add_building = common_tradeport_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = common_tradeport_08 }
                    }
                    add_building = common_tradeport_08
                }
            }
        }
    }
}

DI_tm_destroy_building_common_tradeport_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = common_tradeport }
            }
        }
    }
}

DI_tm_building_pastures_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pastures_01 }
                    }
                    add_building = pastures_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = pastures_02 }
                    }
                    add_building = pastures_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = pastures_03 }
                    }
                    add_building = pastures_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = pastures_04 }
                    }
                    add_building = pastures_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = pastures_05 }
                    }
                    add_building = pastures_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = pastures_06 }
                    }
                    add_building = pastures_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = pastures_07 }
                    }
                    add_building = pastures_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = pastures_08 }
                    }
                    add_building = pastures_08
                }
            }
        }
    }
}

DI_tm_destroy_building_pastures_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = pastures }
            }
        }
    }
}

DI_tm_building_hunting_grounds_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hunting_grounds_01 }
                    }
                    add_building = hunting_grounds_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hunting_grounds_02 }
                    }
                    add_building = hunting_grounds_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hunting_grounds_03 }
                    }
                    add_building = hunting_grounds_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hunting_grounds_04 }
                    }
                    add_building = hunting_grounds_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hunting_grounds_05 }
                    }
                    add_building = hunting_grounds_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = hunting_grounds_06 }
                    }
                    add_building = hunting_grounds_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = hunting_grounds_07 }
                    }
                    add_building = hunting_grounds_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = hunting_grounds_08 }
                    }
                    add_building = hunting_grounds_08
                }
            }
        }
    }
}

DI_tm_destroy_building_hunting_grounds_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = hunting_grounds }
            }
        }
    }
}

DI_tm_building_orchards_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = orchards_01 }
                    }
                    add_building = orchards_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = orchards_02 }
                    }
                    add_building = orchards_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = orchards_03 }
                    }
                    add_building = orchards_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = orchards_04 }
                    }
                    add_building = orchards_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = orchards_05 }
                    }
                    add_building = orchards_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = orchards_06 }
                    }
                    add_building = orchards_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = orchards_07 }
                    }
                    add_building = orchards_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = orchards_08 }
                    }
                    add_building = orchards_08
                }
            }
        }
    }
}

DI_tm_destroy_building_orchards_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = orchards }
            }
        }
    }
}

DI_tm_building_farm_estates_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = farm_estates_01 }
                    }
                    add_building = farm_estates_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = farm_estates_02 }
                    }
                    add_building = farm_estates_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = farm_estates_03 }
                    }
                    add_building = farm_estates_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = farm_estates_04 }
                    }
                    add_building = farm_estates_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = farm_estates_05 }
                    }
                    add_building = farm_estates_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = farm_estates_06 }
                    }
                    add_building = farm_estates_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = farm_estates_07 }
                    }
                    add_building = farm_estates_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = farm_estates_08 }
                    }
                    add_building = farm_estates_08
                }
            }
        }
    }
}

DI_tm_destroy_building_farm_estates_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = farm_estates }
            }
        }
    }
}

DI_tm_building_cereal_fields_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = cereal_fields_01 }
                    }
                    add_building = cereal_fields_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = cereal_fields_02 }
                    }
                    add_building = cereal_fields_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = cereal_fields_03 }
                    }
                    add_building = cereal_fields_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = cereal_fields_04 }
                    }
                    add_building = cereal_fields_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = cereal_fields_05 }
                    }
                    add_building = cereal_fields_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = cereal_fields_06 }
                    }
                    add_building = cereal_fields_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = cereal_fields_07 }
                    }
                    add_building = cereal_fields_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = cereal_fields_08 }
                    }
                    add_building = cereal_fields_08
                }
            }
        }
    }
}

DI_tm_destroy_building_cereal_fields_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = cereal_fields }
            }
        }
    }
}

DI_tm_building_logging_camps_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = logging_camps_01 }
                    }
                    add_building = logging_camps_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = logging_camps_02 }
                    }
                    add_building = logging_camps_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = logging_camps_03 }
                    }
                    add_building = logging_camps_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = logging_camps_04 }
                    }
                    add_building = logging_camps_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = logging_camps_05 }
                    }
                    add_building = logging_camps_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = logging_camps_06 }
                    }
                    add_building = logging_camps_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = logging_camps_07 }
                    }
                    add_building = logging_camps_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = logging_camps_08 }
                    }
                    add_building = logging_camps_08
                }
            }
        }
    }
}

DI_tm_destroy_building_logging_camps_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = logging_camps }
            }
        }
    }
}

DI_tm_building_peat_quarries_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = peat_quarries_01 }
                    }
                    add_building = peat_quarries_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = peat_quarries_02 }
                    }
                    add_building = peat_quarries_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = peat_quarries_03 }
                    }
                    add_building = peat_quarries_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = peat_quarries_04 }
                    }
                    add_building = peat_quarries_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = peat_quarries_05 }
                    }
                    add_building = peat_quarries_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = peat_quarries_06 }
                    }
                    add_building = peat_quarries_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = peat_quarries_07 }
                    }
                    add_building = peat_quarries_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = peat_quarries_08 }
                    }
                    add_building = peat_quarries_08
                }
            }
        }
    }
}

DI_tm_destroy_building_peat_quarries_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = peat_quarries }
            }
        }
    }
}

DI_tm_building_hill_farms_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hill_farms_01 }
                    }
                    add_building = hill_farms_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hill_farms_02 }
                    }
                    add_building = hill_farms_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hill_farms_03 }
                    }
                    add_building = hill_farms_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hill_farms_04 }
                    }
                    add_building = hill_farms_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hill_farms_05 }
                    }
                    add_building = hill_farms_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = hill_farms_06 }
                    }
                    add_building = hill_farms_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = hill_farms_07 }
                    }
                    add_building = hill_farms_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = hill_farms_08 }
                    }
                    add_building = hill_farms_08
                }
            }
        }
    }
}

DI_tm_destroy_building_hill_farms_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = hill_farms }
            }
        }
    }
}

DI_tm_building_elephant_pens_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = elephant_pens_01 }
                    }
                    add_building = elephant_pens_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = elephant_pens_02 }
                    }
                    add_building = elephant_pens_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = elephant_pens_03 }
                    }
                    add_building = elephant_pens_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = elephant_pens_04 }
                    }
                    add_building = elephant_pens_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = elephant_pens_05 }
                    }
                    add_building = elephant_pens_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = elephant_pens_06 }
                    }
                    add_building = elephant_pens_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = elephant_pens_07 }
                    }
                    add_building = elephant_pens_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = elephant_pens_08 }
                    }
                    add_building = elephant_pens_08
                }
            }
        }
    }
}

DI_tm_destroy_building_elephant_pens_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = elephant_pens }
            }
        }
    }
}

DI_tm_building_plantations_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = plantations_01 }
                    }
                    add_building = plantations_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = plantations_02 }
                    }
                    add_building = plantations_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = plantations_03 }
                    }
                    add_building = plantations_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = plantations_04 }
                    }
                    add_building = plantations_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = plantations_05 }
                    }
                    add_building = plantations_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = plantations_06 }
                    }
                    add_building = plantations_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = plantations_07 }
                    }
                    add_building = plantations_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = plantations_08 }
                    }
                    add_building = plantations_08
                }
            }
        }
    }
}

DI_tm_destroy_building_plantations_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = plantations }
            }
        }
    }
}

DI_tm_building_quarries_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = quarries_01 }
                    }
                    add_building = quarries_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = quarries_02 }
                    }
                    add_building = quarries_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = quarries_03 }
                    }
                    add_building = quarries_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = quarries_04 }
                    }
                    add_building = quarries_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = quarries_05 }
                    }
                    add_building = quarries_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = quarries_06 }
                    }
                    add_building = quarries_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = quarries_07 }
                    }
                    add_building = quarries_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = quarries_08 }
                    }
                    add_building = quarries_08
                }
            }
        }
    }
}

DI_tm_destroy_building_quarries_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = quarries }
            }
        }
    }
}

DI_tm_building_ramparts_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ramparts_01 }
                    }
                    add_building = ramparts_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = ramparts_02 }
                    }
                    add_building = ramparts_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = ramparts_03 }
                    }
                    add_building = ramparts_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = ramparts_04 }
                    }
                    add_building = ramparts_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = ramparts_05 }
                    }
                    add_building = ramparts_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = ramparts_06 }
                    }
                    add_building = ramparts_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = ramparts_07 }
                    }
                    add_building = ramparts_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = ramparts_08 }
                    }
                    add_building = ramparts_08
                }
            }
        }
    }
}

DI_tm_destroy_building_ramparts_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = ramparts }
            }
        }
    }
}

DI_tm_building_curtain_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = curtain_walls_01 }
                    }
                    add_building = curtain_walls_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = curtain_walls_02 }
                    }
                    add_building = curtain_walls_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = curtain_walls_03 }
                    }
                    add_building = curtain_walls_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = curtain_walls_04 }
                    }
                    add_building = curtain_walls_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = curtain_walls_05 }
                    }
                    add_building = curtain_walls_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = curtain_walls_06 }
                    }
                    add_building = curtain_walls_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = curtain_walls_07 }
                    }
                    add_building = curtain_walls_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = curtain_walls_08 }
                    }
                    add_building = curtain_walls_08
                }
            }
        }
    }
}

DI_tm_destroy_building_curtain_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = curtain_walls }
            }
        }
    }
}

DI_tm_building_watchtowers_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = watchtowers_01 }
                    }
                    add_building = watchtowers_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = watchtowers_02 }
                    }
                    add_building = watchtowers_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = watchtowers_03 }
                    }
                    add_building = watchtowers_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = watchtowers_04 }
                    }
                    add_building = watchtowers_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = watchtowers_05 }
                    }
                    add_building = watchtowers_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = watchtowers_06 }
                    }
                    add_building = watchtowers_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = watchtowers_07 }
                    }
                    add_building = watchtowers_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = watchtowers_08 }
                    }
                    add_building = watchtowers_08
                }
            }
        }
    }
}

DI_tm_destroy_building_watchtowers_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = watchtowers }
            }
        }
    }
}

DI_tm_building_hill_forts_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hill_forts_01 }
                    }
                    add_building = hill_forts_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hill_forts_02 }
                    }
                    add_building = hill_forts_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hill_forts_03 }
                    }
                    add_building = hill_forts_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hill_forts_04 }
                    }
                    add_building = hill_forts_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hill_forts_05 }
                    }
                    add_building = hill_forts_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = hill_forts_06 }
                    }
                    add_building = hill_forts_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = hill_forts_07 }
                    }
                    add_building = hill_forts_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = hill_forts_08 }
                    }
                    add_building = hill_forts_08
                }
            }
        }
    }
}

DI_tm_destroy_building_hill_forts_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = hill_forts }
            }
        }
    }
}

DI_tm_building_wind_furnace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wind_furnace_01 }
                    }
                    add_building = wind_furnace_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = wind_furnace_02 }
                    }
                    add_building = wind_furnace_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = wind_furnace_03 }
                    }
                    add_building = wind_furnace_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = wind_furnace_04 }
                    }
                    add_building = wind_furnace_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = wind_furnace_05 }
                    }
                    add_building = wind_furnace_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = wind_furnace_06 }
                    }
                    add_building = wind_furnace_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = wind_furnace_07 }
                    }
                    add_building = wind_furnace_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = wind_furnace_08 }
                    }
                    add_building = wind_furnace_08
                }
            }
        }
    }
}

DI_tm_destroy_building_wind_furnace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = wind_furnace }
            }
        }
    }
}

DI_tm_building_powder_magazine_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = powder_magazine_01 }
                    }
                    add_building = powder_magazine_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = powder_magazine_02 }
                    }
                    add_building = powder_magazine_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = powder_magazine_03 }
                    }
                    add_building = powder_magazine_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = powder_magazine_04 }
                    }
                    add_building = powder_magazine_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = powder_magazine_05 }
                    }
                    add_building = powder_magazine_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = powder_magazine_06 }
                    }
                    add_building = powder_magazine_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = powder_magazine_07 }
                    }
                    add_building = powder_magazine_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = powder_magazine_08 }
                    }
                    add_building = powder_magazine_08
                }
            }
        }
    }
}

DI_tm_destroy_building_powder_magazine_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = powder_magazine }
            }
        }
    }
}

DI_tm_building_workshops_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = workshops_01 }
                    }
                    add_building = workshops_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = workshops_02 }
                    }
                    add_building = workshops_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = workshops_03 }
                    }
                    add_building = workshops_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = workshops_04 }
                    }
                    add_building = workshops_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = workshops_05 }
                    }
                    add_building = workshops_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = workshops_06 }
                    }
                    add_building = workshops_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = workshops_07 }
                    }
                    add_building = workshops_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = workshops_08 }
                    }
                    add_building = workshops_08
                }
            }
        }
    }
}

DI_tm_destroy_building_workshops_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = workshops }
            }
        }
    }
}

DI_tm_building_horse_pastures_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = horse_pastures_01 }
                    }
                    add_building = horse_pastures_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = horse_pastures_02 }
                    }
                    add_building = horse_pastures_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = horse_pastures_03 }
                    }
                    add_building = horse_pastures_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = horse_pastures_04 }
                    }
                    add_building = horse_pastures_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = horse_pastures_05 }
                    }
                    add_building = horse_pastures_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = horse_pastures_06 }
                    }
                    add_building = horse_pastures_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = horse_pastures_07 }
                    }
                    add_building = horse_pastures_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = horse_pastures_08 }
                    }
                    add_building = horse_pastures_08
                }
            }
        }
    }
}

DI_tm_destroy_building_horse_pastures_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = horse_pastures }
            }
        }
    }
}

DI_tm_building_hillside_grazing_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = hillside_grazing_01 }
                    }
                    add_building = hillside_grazing_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = hillside_grazing_02 }
                    }
                    add_building = hillside_grazing_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = hillside_grazing_03 }
                    }
                    add_building = hillside_grazing_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = hillside_grazing_04 }
                    }
                    add_building = hillside_grazing_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = hillside_grazing_05 }
                    }
                    add_building = hillside_grazing_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = hillside_grazing_06 }
                    }
                    add_building = hillside_grazing_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = hillside_grazing_07 }
                    }
                    add_building = hillside_grazing_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = hillside_grazing_08 }
                    }
                    add_building = hillside_grazing_08
                }
            }
        }
    }
}

DI_tm_destroy_building_hillside_grazing_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = hillside_grazing }
            }
        }
    }
}

DI_tm_building_warrior_lodges_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = warrior_lodges_01 }
                    }
                    add_building = warrior_lodges_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = warrior_lodges_02 }
                    }
                    add_building = warrior_lodges_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = warrior_lodges_03 }
                    }
                    add_building = warrior_lodges_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = warrior_lodges_04 }
                    }
                    add_building = warrior_lodges_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = warrior_lodges_05 }
                    }
                    add_building = warrior_lodges_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = warrior_lodges_06 }
                    }
                    add_building = warrior_lodges_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = warrior_lodges_07 }
                    }
                    add_building = warrior_lodges_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = warrior_lodges_08 }
                    }
                    add_building = warrior_lodges_08
                }
            }
        }
    }
}

DI_tm_destroy_building_warrior_lodges_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = warrior_lodges }
            }
        }
    }
}

DI_tm_building_military_camps_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = military_camps_01 }
                    }
                    add_building = military_camps_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = military_camps_02 }
                    }
                    add_building = military_camps_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = military_camps_03 }
                    }
                    add_building = military_camps_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = military_camps_04 }
                    }
                    add_building = military_camps_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = military_camps_05 }
                    }
                    add_building = military_camps_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = military_camps_06 }
                    }
                    add_building = military_camps_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = military_camps_07 }
                    }
                    add_building = military_camps_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = military_camps_08 }
                    }
                    add_building = military_camps_08
                }
            }
        }
    }
}

DI_tm_destroy_building_military_camps_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = military_camps }
            }
        }
    }
}

DI_tm_building_regimental_grounds_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = regimental_grounds_01 }
                    }
                    add_building = regimental_grounds_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = regimental_grounds_02 }
                    }
                    add_building = regimental_grounds_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = regimental_grounds_03 }
                    }
                    add_building = regimental_grounds_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = regimental_grounds_04 }
                    }
                    add_building = regimental_grounds_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = regimental_grounds_05 }
                    }
                    add_building = regimental_grounds_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = regimental_grounds_06 }
                    }
                    add_building = regimental_grounds_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = regimental_grounds_07 }
                    }
                    add_building = regimental_grounds_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = regimental_grounds_08 }
                    }
                    add_building = regimental_grounds_08
                }
            }
        }
    }
}

DI_tm_destroy_building_regimental_grounds_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = regimental_grounds }
            }
        }
    }
}

DI_tm_building_outposts_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = outposts_01 }
                    }
                    add_building = outposts_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = outposts_02 }
                    }
                    add_building = outposts_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = outposts_03 }
                    }
                    add_building = outposts_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = outposts_04 }
                    }
                    add_building = outposts_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = outposts_05 }
                    }
                    add_building = outposts_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = outposts_06 }
                    }
                    add_building = outposts_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = outposts_07 }
                    }
                    add_building = outposts_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = outposts_08 }
                    }
                    add_building = outposts_08
                }
            }
        }
    }
}

DI_tm_destroy_building_outposts_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = outposts }
            }
        }
    }
}

DI_tm_building_barracks_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = barracks_01 }
                    }
                    add_building = barracks_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = barracks_02 }
                    }
                    add_building = barracks_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = barracks_03 }
                    }
                    add_building = barracks_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = barracks_04 }
                    }
                    add_building = barracks_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = barracks_05 }
                    }
                    add_building = barracks_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = barracks_06 }
                    }
                    add_building = barracks_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = barracks_07 }
                    }
                    add_building = barracks_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = barracks_08 }
                    }
                    add_building = barracks_08
                }
            }
        }
    }
}

DI_tm_destroy_building_barracks_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = barracks }
            }
        }
    }
}

DI_tm_building_camel_farms_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = camel_farms_01 }
                    }
                    add_building = camel_farms_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = camel_farms_02 }
                    }
                    add_building = camel_farms_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = camel_farms_03 }
                    }
                    add_building = camel_farms_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = camel_farms_04 }
                    }
                    add_building = camel_farms_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = camel_farms_05 }
                    }
                    add_building = camel_farms_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = camel_farms_06 }
                    }
                    add_building = camel_farms_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = camel_farms_07 }
                    }
                    add_building = camel_farms_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = camel_farms_08 }
                    }
                    add_building = camel_farms_08
                }
            }
        }
    }
}

DI_tm_destroy_building_camel_farms_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = camel_farms }
            }
        }
    }
}

DI_tm_building_stables_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = stables_01 }
                    }
                    add_building = stables_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = stables_02 }
                    }
                    add_building = stables_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = stables_03 }
                    }
                    add_building = stables_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = stables_04 }
                    }
                    add_building = stables_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = stables_05 }
                    }
                    add_building = stables_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = stables_06 }
                    }
                    add_building = stables_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = stables_07 }
                    }
                    add_building = stables_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = stables_08 }
                    }
                    add_building = stables_08
                }
            }
        }
    }
}

DI_tm_destroy_building_stables_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = stables }
            }
        }
    }
}

DI_tm_building_smiths_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = smiths_01 }
                    }
                    add_building = smiths_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = smiths_02 }
                    }
                    add_building = smiths_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = smiths_03 }
                    }
                    add_building = smiths_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = smiths_04 }
                    }
                    add_building = smiths_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = smiths_05 }
                    }
                    add_building = smiths_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = smiths_06 }
                    }
                    add_building = smiths_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = smiths_07 }
                    }
                    add_building = smiths_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = smiths_08 }
                    }
                    add_building = smiths_08
                }
            }
        }
    }
}

DI_tm_destroy_building_smiths_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = smiths }
            }
        }
    }
}

DI_tm_building_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = temple_01 }
                    }
                    set_holding_type = church_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = temple_01 }
                    }
                    add_building = temple_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = temple_02 }
                    }
                    add_building = temple_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = temple_03 }
                    }
                    add_building = temple_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = temple_04 }
                    }
                    add_building = temple_04
                }
            }
        }
    }
}

DI_tm_destroy_building_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = temple_04 } remove_building = temple_04 }
                else_if = { limit = { has_building = temple_03 } remove_building = temple_03 }
                else_if = { limit = { has_building = temple_02 } remove_building = temple_02 }
                else_if = { limit = { has_building = temple_01 } remove_building = temple_01 }
            }
        }
    }
}

DI_tm_building_scriptorium_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = scriptorium_01 }
                    }
                    add_building = scriptorium_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = scriptorium_02 }
                    }
                    add_building = scriptorium_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = scriptorium_03 }
                    }
                    add_building = scriptorium_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = scriptorium_04 }
                    }
                    add_building = scriptorium_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = scriptorium_05 }
                    }
                    add_building = scriptorium_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = scriptorium_06 }
                    }
                    add_building = scriptorium_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = scriptorium_07 }
                    }
                    add_building = scriptorium_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = scriptorium_08 }
                    }
                    add_building = scriptorium_08
                }
            }
        }
    }
}

DI_tm_destroy_building_scriptorium_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = scriptorium }
            }
        }
    }
}

DI_tm_building_monastic_schools_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = monastic_schools_01 }
                    }
                    add_building = monastic_schools_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = monastic_schools_02 }
                    }
                    add_building = monastic_schools_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = monastic_schools_03 }
                    }
                    add_building = monastic_schools_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = monastic_schools_04 }
                    }
                    add_building = monastic_schools_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = monastic_schools_05 }
                    }
                    add_building = monastic_schools_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = monastic_schools_06 }
                    }
                    add_building = monastic_schools_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = monastic_schools_07 }
                    }
                    add_building = monastic_schools_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = monastic_schools_08 }
                    }
                    add_building = monastic_schools_08
                }
            }
        }
    }
}

DI_tm_destroy_building_monastic_schools_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = monastic_schools }
            }
        }
    }
}

DI_tm_building_megalith_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = megalith_01 }
                    }
                    add_building = megalith_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = megalith_02 }
                    }
                    add_building = megalith_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = megalith_03 }
                    }
                    add_building = megalith_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = megalith_04 }
                    }
                    add_building = megalith_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = megalith_05 }
                    }
                    add_building = megalith_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = megalith_06 }
                    }
                    add_building = megalith_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = megalith_07 }
                    }
                    add_building = megalith_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = megalith_08 }
                    }
                    add_building = megalith_08
                }
            }
        }
    }
}

DI_tm_destroy_building_megalith_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = megalith }
            }
        }
    }
}

DI_tm_building_breweries_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = breweries_01 }
                    }
                    add_building = breweries_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = breweries_02 }
                    }
                    add_building = breweries_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = breweries_03 }
                    }
                    add_building = breweries_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = breweries_04 }
                    }
                    add_building = breweries_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = breweries_05 }
                    }
                    add_building = breweries_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = breweries_06 }
                    }
                    add_building = breweries_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = breweries_07 }
                    }
                    add_building = breweries_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = breweries_08 }
                    }
                    add_building = breweries_08
                }
            }
        }
    }
}

DI_tm_destroy_building_breweries_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = breweries }
            }
        }
    }
}

DI_tm_building_tribe_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = tribe_01 }
                    }
                    set_holding_type = tribal_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = tribe_01 }
                    }
                    add_building = tribe_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = tribe_02 }
                    }
                    add_building = tribe_02
                }
            }
        }
    }
}

DI_tm_destroy_building_tribe_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = tribe_02 } remove_building = tribe_02 }
                else_if = { limit = { has_building = tribe_01 } remove_building = tribe_01 }
            }
        }
    }
}

DI_tm_building_longhouses_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = longhouses_01 }
                    }
                    add_building = longhouses_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = longhouses_02 }
                    }
                    add_building = longhouses_02
                }
            }
        }
    }
}

DI_tm_destroy_building_longhouses_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = longhouses_02 } remove_building = longhouses_02 }
                else_if = { limit = { has_building = longhouses_01 } remove_building = longhouses_01 }
            }
        }
    }
}

DI_tm_building_war_camps_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = war_camps_01 }
                    }
                    add_building = war_camps_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = war_camps_02 }
                    }
                    add_building = war_camps_02
                }
            }
        }
    }
}

DI_tm_destroy_building_war_camps_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = war_camps_02 } remove_building = war_camps_02 }
                else_if = { limit = { has_building = war_camps_01 } remove_building = war_camps_01 }
            }
        }
    }
}

DI_tm_building_palisades_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = palisades_01 }
                    }
                    add_building = palisades_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = palisades_02 }
                    }
                    add_building = palisades_02
                }
            }
        }
    }
}

DI_tm_destroy_building_palisades_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = palisades_02 } remove_building = palisades_02 }
                else_if = { limit = { has_building = palisades_01 } remove_building = palisades_01 }
            }
        }
    }
}

DI_tm_building_market_villages_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = market_villages_01 }
                    }
                    add_building = market_villages_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = market_villages_02 }
                    }
                    add_building = market_villages_02
                }
            }
        }
    }
}

DI_tm_destroy_building_market_villages_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = market_villages_02 } remove_building = market_villages_02 }
                else_if = { limit = { has_building = market_villages_01 } remove_building = market_villages_01 }
            }
        }
    }
}

DI_tm_building_idjang_forts_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = idjang_forts_01 }
                    }
                    add_building = idjang_forts_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = idjang_forts_02 }
                    }
                    add_building = idjang_forts_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = idjang_forts_03 }
                    }
                    add_building = idjang_forts_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = idjang_forts_04 }
                    }
                    add_building = idjang_forts_04
                }
            }
        }
    }
}

DI_tm_destroy_building_idjang_forts_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = idjang_forts_04 } remove_building = idjang_forts_04 }
                else_if = { limit = { has_building = idjang_forts_03 } remove_building = idjang_forts_03 }
                else_if = { limit = { has_building = idjang_forts_02 } remove_building = idjang_forts_02 }
                else_if = { limit = { has_building = idjang_forts_01 } remove_building = idjang_forts_01 }
            }
        }
    }
}

DI_tm_building_wantilan_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wantilan_01 }
                    }
                    add_building = wantilan_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = wantilan_02 }
                    }
                    add_building = wantilan_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = wantilan_03 }
                    }
                    add_building = wantilan_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = wantilan_04 }
                    }
                    add_building = wantilan_04
                }
            }
        }
    }
}

DI_tm_destroy_building_wantilan_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wantilan_04 } remove_building = wantilan_04 }
                else_if = { limit = { has_building = wantilan_03 } remove_building = wantilan_03 }
                else_if = { limit = { has_building = wantilan_02 } remove_building = wantilan_02 }
                else_if = { limit = { has_building = wantilan_01 } remove_building = wantilan_01 }
            }
        }
    }
}

DI_tm_building_kora_kora_yards_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kora_kora_yards_01 }
                    }
                    add_building = kora_kora_yards_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = kora_kora_yards_02 }
                    }
                    add_building = kora_kora_yards_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = kora_kora_yards_03 }
                    }
                    add_building = kora_kora_yards_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = kora_kora_yards_04 }
                    }
                    add_building = kora_kora_yards_04
                }
            }
        }
    }
}

DI_tm_destroy_building_kora_kora_yards_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kora_kora_yards_04 } remove_building = kora_kora_yards_04 }
                else_if = { limit = { has_building = kora_kora_yards_03 } remove_building = kora_kora_yards_03 }
                else_if = { limit = { has_building = kora_kora_yards_02 } remove_building = kora_kora_yards_02 }
                else_if = { limit = { has_building = kora_kora_yards_01 } remove_building = kora_kora_yards_01 }
            }
        }
    }
}

DI_tm_building_water_temples_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = water_temples_01 }
                    }
                    add_building = water_temples_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = water_temples_02 }
                    }
                    add_building = water_temples_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = water_temples_03 }
                    }
                    add_building = water_temples_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = water_temples_04 }
                    }
                    add_building = water_temples_04
                }
            }
        }
    }
}

DI_tm_destroy_building_water_temples_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = water_temples_04 } remove_building = water_temples_04 }
                else_if = { limit = { has_building = water_temples_03 } remove_building = water_temples_03 }
                else_if = { limit = { has_building = water_temples_02 } remove_building = water_temples_02 }
                else_if = { limit = { has_building = water_temples_01 } remove_building = water_temples_01 }
            }
        }
    }
}

DI_tm_building_stilted_granaries_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = stilted_granaries_01 }
                    }
                    add_building = stilted_granaries_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = stilted_granaries_02 }
                    }
                    add_building = stilted_granaries_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = stilted_granaries_03 }
                    }
                    add_building = stilted_granaries_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = stilted_granaries_04 }
                    }
                    add_building = stilted_granaries_04
                }
            }
        }
    }
}

DI_tm_destroy_building_stilted_granaries_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = stilted_granaries_04 } remove_building = stilted_granaries_04 }
                else_if = { limit = { has_building = stilted_granaries_03 } remove_building = stilted_granaries_03 }
                else_if = { limit = { has_building = stilted_granaries_02 } remove_building = stilted_granaries_02 }
                else_if = { limit = { has_building = stilted_granaries_01 } remove_building = stilted_granaries_01 }
            }
        }
    }
}

DI_tm_building_oath_warriors_building_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = oath_warriors_building_01 }
                    }
                    add_building = oath_warriors_building_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = oath_warriors_building_02 }
                    }
                    add_building = oath_warriors_building_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = oath_warriors_building_03 }
                    }
                    add_building = oath_warriors_building_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = oath_warriors_building_04 }
                    }
                    add_building = oath_warriors_building_04
                }
            }
        }
    }
}

DI_tm_destroy_building_oath_warriors_building_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = oath_warriors_building_04 } remove_building = oath_warriors_building_04 }
                else_if = { limit = { has_building = oath_warriors_building_03 } remove_building = oath_warriors_building_03 }
                else_if = { limit = { has_building = oath_warriors_building_02 } remove_building = oath_warriors_building_02 }
                else_if = { limit = { has_building = oath_warriors_building_01 } remove_building = oath_warriors_building_01 }
            }
        }
    }
}

DI_tm_building_oath_faithful_building_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = oath_faithful_building_01 }
                    }
                    add_building = oath_faithful_building_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = oath_faithful_building_02 }
                    }
                    add_building = oath_faithful_building_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = oath_faithful_building_03 }
                    }
                    add_building = oath_faithful_building_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = oath_faithful_building_04 }
                    }
                    add_building = oath_faithful_building_04
                }
            }
        }
    }
}

DI_tm_destroy_building_oath_faithful_building_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = oath_faithful_building_04 } remove_building = oath_faithful_building_04 }
                else_if = { limit = { has_building = oath_faithful_building_03 } remove_building = oath_faithful_building_03 }
                else_if = { limit = { has_building = oath_faithful_building_02 } remove_building = oath_faithful_building_02 }
                else_if = { limit = { has_building = oath_faithful_building_01 } remove_building = oath_faithful_building_01 }
            }
        }
    }
}

DI_tm_building_oath_poor_building_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = oath_poor_building_01 }
                    }
                    add_building = oath_poor_building_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = oath_poor_building_02 }
                    }
                    add_building = oath_poor_building_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = oath_poor_building_03 }
                    }
                    add_building = oath_poor_building_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = oath_poor_building_04 }
                    }
                    add_building = oath_poor_building_04
                }
            }
        }
    }
}

DI_tm_destroy_building_oath_poor_building_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = oath_poor_building_04 } remove_building = oath_poor_building_04 }
                else_if = { limit = { has_building = oath_poor_building_03 } remove_building = oath_poor_building_03 }
                else_if = { limit = { has_building = oath_poor_building_02 } remove_building = oath_poor_building_02 }
                else_if = { limit = { has_building = oath_poor_building_01 } remove_building = oath_poor_building_01 }
            }
        }
    }
}

DI_tm_building_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = walls_00 }
                    }
                    add_building = walls_00
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = walls_01 }
                    }
                    add_building = walls_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = walls_02 }
                    }
                    add_building = walls_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = walls_03 }
                    }
                    add_building = walls_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = walls_04 }
                    }
                    add_building = walls_04
                }
            }
        }
    }
}

DI_tm_destroy_building_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = walls_04 } remove_building = walls_04 }
                else_if = { limit = { has_building = walls_03 } remove_building = walls_03 }
                else_if = { limit = { has_building = walls_02 } remove_building = walls_02 }
                else_if = { limit = { has_building = walls_01 } remove_building = walls_01 }
                else_if = { limit = { has_building = walls_00 } remove_building = walls_00 }
            }
        }
    }
}

DI_tm_building_walls_01_tribal_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = walls_01_tribal }
                    }
                    add_building = walls_01_tribal
                }
            }
        }
    }
}

DI_tm_destroy_building_walls_01_tribal_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = walls_01_tribal } remove_building = walls_01_tribal }
            }
        }
    }
}

DI_tm_building_drassanes_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = drassanes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = drassanes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = drassanes_01
                }
            }
        }
    }
}

DI_tm_destroy_building_drassanes_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = drassanes_01 } remove_building = drassanes_01 }
            }
        }
    }
}

DI_tm_building_kyz_kala_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kyz_kala_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kyz_kala_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kyz_kala_01
                }
            }
        }
    }
}

DI_tm_destroy_building_kyz_kala_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kyz_kala_01 } remove_building = kyz_kala_01 }
            }
        }
    }
}

DI_tm_building_cluny_abbey_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = cluny_abbey_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cluny_abbey_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cluny_abbey_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = cluny_abbey_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cluny_abbey_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cluny_abbey_02
                }
            }
        }
    }
}

DI_tm_destroy_building_cluny_abbey_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = cluny_abbey_02 } remove_building = cluny_abbey_02 }
                else_if = { limit = { has_building = cluny_abbey_01 } remove_building = cluny_abbey_01 }
            }
        }
    }
}

DI_tm_building_york_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = york_walls_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = york_walls_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = york_walls_01
                }
            }
        }
    }
}

DI_tm_destroy_building_york_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = york_walls_01 } remove_building = york_walls_01 }
            }
        }
    }
}

DI_tm_building_damascus_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = damascus_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = damascus_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = damascus_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_damascus_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = damascus_mosque_01 } remove_building = damascus_mosque_01 }
            }
        }
    }
}

DI_tm_building_jokhang_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jokhang_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jokhang_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jokhang_01
                }
            }
        }
    }
}

DI_tm_destroy_building_jokhang_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jokhang_01 } remove_building = jokhang_01 }
            }
        }
    }
}

DI_tm_building_wartburg_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wartburg_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wartburg_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wartburg_01
                }
            }
        }
    }
}

DI_tm_destroy_building_wartburg_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wartburg_01 } remove_building = wartburg_01 }
            }
        }
    }
}

DI_tm_building_beta_giyorgis_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = beta_giyorgis_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = beta_giyorgis_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = beta_giyorgis_01
                }
            }
        }
    }
}

DI_tm_destroy_building_beta_giyorgis_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = beta_giyorgis_01 } remove_building = beta_giyorgis_01 }
            }
        }
    }
}

DI_tm_building_holy_wisdom_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_wisdom_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_wisdom_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_wisdom_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_wisdom_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_wisdom_01 } remove_building = holy_wisdom_01 }
            }
        }
    }
}

DI_tm_building_kano_walls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kano_walls_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kano_walls_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kano_walls_01
                }
            }
        }
    }
}

DI_tm_destroy_building_kano_walls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kano_walls_01 } remove_building = kano_walls_01 }
            }
        }
    }
}

DI_tm_building_somapura_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = somapura_university_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = somapura_university_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = somapura_university_01
                }
            }
        }
    }
}

DI_tm_destroy_building_somapura_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = somapura_university_01 } remove_building = somapura_university_01 }
            }
        }
    }
}

DI_tm_building_duomo_florence_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = duomo_florence_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = duomo_florence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = duomo_florence_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = duomo_florence_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = duomo_florence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = duomo_florence_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = duomo_florence_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = duomo_florence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = duomo_florence_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = duomo_florence_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = duomo_florence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = duomo_florence_04
                }
            }
        }
    }
}

DI_tm_destroy_building_duomo_florence_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = duomo_florence_04 } remove_building = duomo_florence_04 }
                else_if = { limit = { has_building = duomo_florence_03 } remove_building = duomo_florence_03 }
                else_if = { limit = { has_building = duomo_florence_02 } remove_building = duomo_florence_02 }
                else_if = { limit = { has_building = duomo_florence_01 } remove_building = duomo_florence_01 }
            }
        }
    }
}

DI_tm_building_konark_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = konark_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konark_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konark_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_konark_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = konark_temple_01 } remove_building = konark_temple_01 }
            }
        }
    }
}

DI_tm_building_al_qarawiyyin_university_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = al_qarawiyyin_university_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = al_qarawiyyin_university_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = al_qarawiyyin_university_01
                }
            }
        }
    }
}

DI_tm_destroy_building_al_qarawiyyin_university_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = al_qarawiyyin_university_01 } remove_building = al_qarawiyyin_university_01 }
            }
        }
    }
}

DI_tm_building_kairouan_basins_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = kairouan_basins_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kairouan_basins_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kairouan_basins_01
                }
            }
        }
    }
}

DI_tm_destroy_building_kairouan_basins_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = kairouan_basins_01 } remove_building = kairouan_basins_01 }
            }
        }
    }
}

DI_tm_building_ghana_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ghana_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ghana_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ghana_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_ghana_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ghana_palace_01 } remove_building = ghana_palace_01 }
            }
        }
    }
}

DI_tm_building_visegrad_castle_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = visegrad_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = visegrad_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = visegrad_castle_01
                }
            }
        }
    }
}

DI_tm_destroy_building_visegrad_castle_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = visegrad_castle_01 } remove_building = visegrad_castle_01 }
            }
        }
    }
}

DI_tm_building_wawel_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wawel_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wawel_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wawel_cathedral_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = wawel_cathedral_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wawel_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wawel_cathedral_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = wawel_cathedral_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wawel_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wawel_cathedral_03
                }
            }
        }
    }
}

DI_tm_destroy_building_wawel_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wawel_cathedral_03 } remove_building = wawel_cathedral_03 }
                else_if = { limit = { has_building = wawel_cathedral_02 } remove_building = wawel_cathedral_02 }
                else_if = { limit = { has_building = wawel_cathedral_01 } remove_building = wawel_cathedral_01 }
            }
        }
    }
}

DI_tm_building_vatapi_caves_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = vatapi_caves_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = vatapi_caves_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = vatapi_caves_01
                }
            }
        }
    }
}

DI_tm_destroy_building_vatapi_caves_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = vatapi_caves_01 } remove_building = vatapi_caves_01 }
            }
        }
    }
}

DI_tm_building_jaisalmer_fort_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = jaisalmer_fort_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jaisalmer_fort_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jaisalmer_fort_01
                }
            }
        }
    }
}

DI_tm_destroy_building_jaisalmer_fort_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = jaisalmer_fort_01 } remove_building = jaisalmer_fort_01 }
            }
        }
    }
}

DI_tm_building_holy_site_st_peters_basilica_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = holy_site_st_peters_basilica_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_st_peters_basilica_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_st_peters_basilica_01
                }
            }
        }
    }
}

DI_tm_destroy_building_holy_site_st_peters_basilica_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = holy_site_st_peters_basilica_01 } remove_building = holy_site_st_peters_basilica_01 }
            }
        }
    }
}

DI_tm_building_mont_st_michel_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mont_st_michel_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mont_st_michel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mont_st_michel_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = mont_st_michel_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mont_st_michel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mont_st_michel_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = mont_st_michel_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mont_st_michel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mont_st_michel_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = mont_st_michel_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mont_st_michel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mont_st_michel_04
                }
            }
        }
    }
}

DI_tm_destroy_building_mont_st_michel_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mont_st_michel_04 } remove_building = mont_st_michel_04 }
                else_if = { limit = { has_building = mont_st_michel_03 } remove_building = mont_st_michel_03 }
                else_if = { limit = { has_building = mont_st_michel_02 } remove_building = mont_st_michel_02 }
                else_if = { limit = { has_building = mont_st_michel_01 } remove_building = mont_st_michel_01 }
            }
        }
    }
}

DI_tm_building_sanchi_stupa_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sanchi_stupa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sanchi_stupa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sanchi_stupa_01
                }
            }
        }
    }
}

DI_tm_destroy_building_sanchi_stupa_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = sanchi_stupa_01 } remove_building = sanchi_stupa_01 }
            }
        }
    }
}

DI_tm_building_boudhanath_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = boudhanath_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = boudhanath_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = boudhanath_01
                }
            }
        }
    }
}

DI_tm_destroy_building_boudhanath_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = boudhanath_01 } remove_building = boudhanath_01 }
            }
        }
    }
}

DI_tm_building_yazd_mosque_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = yazd_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yazd_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yazd_mosque_01
                }
            }
        }
    }
}

DI_tm_destroy_building_yazd_mosque_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = yazd_mosque_01 } remove_building = yazd_mosque_01 }
            }
        }
    }
}

DI_tm_building_qutb_minar_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = qutb_minar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qutb_minar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qutb_minar_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = qutb_minar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qutb_minar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qutb_minar_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = qutb_minar_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qutb_minar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qutb_minar_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = qutb_minar_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qutb_minar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qutb_minar_04
                }
            }
        }
    }
}

DI_tm_destroy_building_qutb_minar_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = qutb_minar_04 } remove_building = qutb_minar_04 }
                else_if = { limit = { has_building = qutb_minar_03 } remove_building = qutb_minar_03 }
                else_if = { limit = { has_building = qutb_minar_02 } remove_building = qutb_minar_02 }
                else_if = { limit = { has_building = qutb_minar_01 } remove_building = qutb_minar_01 }
            }
        }
    }
}

DI_tm_building_goguryeo_tomb_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = goguryeo_tomb_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = goguryeo_tomb_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = goguryeo_tomb_01
                }
            }
        }
    }
}

DI_tm_destroy_building_goguryeo_tomb_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = goguryeo_tomb_01 } remove_building = goguryeo_tomb_01 }
            }
        }
    }
}

DI_tm_building_buddha_kamakura_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = buddha_kamakura_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = buddha_kamakura_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = buddha_kamakura_01
                }
            }
        }
    }
}

DI_tm_destroy_building_buddha_kamakura_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = buddha_kamakura_01 } remove_building = buddha_kamakura_01 }
            }
        }
    }
}

DI_tm_building_pyramid_lingapura_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pyramid_lingapura_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pyramid_lingapura_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pyramid_lingapura_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pyramid_lingapura_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pyramid_lingapura_01 } remove_building = pyramid_lingapura_01 }
            }
        }
    }
}

DI_tm_building_maijishan_grottoes_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = maijishan_grottoes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maijishan_grottoes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maijishan_grottoes_01
                }
            }
        }
    }
}

DI_tm_destroy_building_maijishan_grottoes_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = maijishan_grottoes_01 } remove_building = maijishan_grottoes_01 }
            }
        }
    }
}

DI_tm_building_three_pagodas_dali_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = three_pagodas_dali_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = three_pagodas_dali_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = three_pagodas_dali_01
                }
            }
        }
    }
}

DI_tm_destroy_building_three_pagodas_dali_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = three_pagodas_dali_01 } remove_building = three_pagodas_dali_01 }
            }
        }
    }
}

DI_tm_building_iron_lion_cangzhou_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = iron_lion_cangzhou_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_lion_cangzhou_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_lion_cangzhou_01
                }
            }
        }
    }
}

DI_tm_destroy_building_iron_lion_cangzhou_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = iron_lion_cangzhou_01 } remove_building = iron_lion_cangzhou_01 }
            }
        }
    }
}

DI_tm_building_dengfeng_observatory_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = dengfeng_observatory_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dengfeng_observatory_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dengfeng_observatory_01
                }
            }
        }
    }
}

DI_tm_destroy_building_dengfeng_observatory_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = dengfeng_observatory_01 } remove_building = dengfeng_observatory_01 }
            }
        }
    }
}

DI_tm_building_muara_takus_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = muara_takus_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = muara_takus_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = muara_takus_01
                }
            }
        }
    }
}

DI_tm_destroy_building_muara_takus_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = muara_takus_01 } remove_building = muara_takus_01 }
            }
        }
    }
}

DI_tm_building_stone_pagoda_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = stone_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = stone_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = stone_pagoda_01
                }
            }
        }
    }
}

DI_tm_destroy_building_stone_pagoda_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = stone_pagoda_01 } remove_building = stone_pagoda_01 }
            }
        }
    }
}

DI_tm_building_thuriang_kilns_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = thuriang_kilns_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = thuriang_kilns_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = thuriang_kilns_01
                }
            }
        }
    }
}

DI_tm_destroy_building_thuriang_kilns_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = thuriang_kilns_01 } remove_building = thuriang_kilns_01 }
            }
        }
    }
}

DI_tm_building_yuelu_academy_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = yuelu_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yuelu_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yuelu_academy_01
                }
            }
        }
    }
}

DI_tm_destroy_building_yuelu_academy_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = yuelu_academy_01 } remove_building = yuelu_academy_01 }
            }
        }
    }
}

DI_tm_building_chocolate_hills_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = chocolate_hills_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chocolate_hills_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chocolate_hills_01
                }
            }
        }
    }
}

DI_tm_destroy_building_chocolate_hills_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = chocolate_hills_01 } remove_building = chocolate_hills_01 }
            }
        }
    }
}

DI_tm_building_fanfang_guangzhou_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = fanfang_guangzhou_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fanfang_guangzhou_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fanfang_guangzhou_01
                }
            }
        }
    }
}

DI_tm_destroy_building_fanfang_guangzhou_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = fanfang_guangzhou_01 } remove_building = fanfang_guangzhou_01 }
            }
        }
    }
}

DI_tm_building_wilwatikta_palace_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = wilwatikta_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wilwatikta_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wilwatikta_palace_01
                }
            }
        }
    }
}

DI_tm_destroy_building_wilwatikta_palace_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = wilwatikta_palace_01 } remove_building = wilwatikta_palace_01 }
            }
        }
    }
}

DI_tm_building_ha_long_bay_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = ha_long_bay_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ha_long_bay_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ha_long_bay_01
                }
            }
        }
    }
}

DI_tm_destroy_building_ha_long_bay_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = ha_long_bay_01 } remove_building = ha_long_bay_01 }
            }
        }
    }
}

DI_tm_building_my_son_sanctuary_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = my_son_sanctuary_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = my_son_sanctuary_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = my_son_sanctuary_01
                }
            }
        }
    }
}

DI_tm_destroy_building_my_son_sanctuary_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = my_son_sanctuary_01 } remove_building = my_son_sanctuary_01 }
            }
        }
    }
}

DI_tm_building_gunung_api_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = gunung_api_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = gunung_api_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = gunung_api_01
                }
            }
        }
    }
}

DI_tm_destroy_building_gunung_api_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = gunung_api_01 } remove_building = gunung_api_01 }
            }
        }
    }
}

DI_tm_building_suwalesi_megaliths_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = suwalesi_megaliths_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suwalesi_megaliths_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suwalesi_megaliths_01
                }
            }
        }
    }
}

DI_tm_destroy_building_suwalesi_megaliths_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = suwalesi_megaliths_01 } remove_building = suwalesi_megaliths_01 }
            }
        }
    }
}

DI_tm_building_izumo_taisha_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = izumo_taisha_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = izumo_taisha_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = izumo_taisha_01
                }
            }
        }
    }
}

DI_tm_destroy_building_izumo_taisha_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = izumo_taisha_01 } remove_building = izumo_taisha_01 }
            }
        }
    }
}

DI_tm_building_confucius_temple_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = confucius_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = confucius_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = confucius_temple_01
                }
            }
        }
    }
}

DI_tm_destroy_building_confucius_temple_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = confucius_temple_01 } remove_building = confucius_temple_01 }
            }
        }
    }
}

DI_tm_building_citadel_linan_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = citadel_linan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_linan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_linan_01
                }
            }
        }
    }
}

DI_tm_destroy_building_citadel_linan_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = citadel_linan_01 } remove_building = citadel_linan_01 }
            }
        }
    }
}

DI_tm_building_temples_angkor_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = temples_angkor_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temples_angkor_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temples_angkor_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = temples_angkor_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temples_angkor_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temples_angkor_02
                }
            }
        }
    }
}

DI_tm_destroy_building_temples_angkor_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = temples_angkor_02 } remove_building = temples_angkor_02 }
                else_if = { limit = { has_building = temples_angkor_01 } remove_building = temples_angkor_01 }
            }
        }
    }
}

DI_tm_building_great_project_cathedral_under_construction_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = great_project_cathedral_under_construction }
                    }
                    add_building = great_project_cathedral_under_construction
                }
            }
        }
    }
}

DI_tm_destroy_building_great_project_cathedral_under_construction_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = great_project_cathedral_under_construction } remove_building = great_project_cathedral_under_construction }
            }
        }
    }
}

DI_tm_building_great_project_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = great_project_cathedral_01 }
                    }
                    add_building = great_project_cathedral_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = great_project_cathedral_02 }
                    }
                    add_building = great_project_cathedral_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = great_project_cathedral_03 }
                    }
                    add_building = great_project_cathedral_03
                }
            }
        }
    }
}

DI_tm_destroy_building_great_project_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = great_project_cathedral_03 } remove_building = great_project_cathedral_03 }
                else_if = { limit = { has_building = great_project_cathedral_02 } remove_building = great_project_cathedral_02 }
                else_if = { limit = { has_building = great_project_cathedral_01 } remove_building = great_project_cathedral_01 }
            }
        }
    }
}

DI_tm_building_pam_abbey_of_st_gall_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pam_abbey_of_st_gall_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_abbey_of_st_gall_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_abbey_of_st_gall_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pam_abbey_of_st_gall_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pam_abbey_of_st_gall_01 } remove_building = pam_abbey_of_st_gall_01 }
            }
        }
    }
}

DI_tm_building_pam_palais_de_papes_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pam_palais_de_papes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_palais_de_papes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_palais_de_papes_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pam_palais_de_papes_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pam_palais_de_papes_01 } remove_building = pam_palais_de_papes_01 }
            }
        }
    }
}

DI_tm_building_pam_lateran_basilica_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pam_lateran_basilica_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_lateran_basilica_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_lateran_basilica_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pam_lateran_basilica_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pam_lateran_basilica_01 } remove_building = pam_lateran_basilica_01 }
            }
        }
    }
}

DI_tm_building_pam_reims_cathedral_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = pam_reims_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_reims_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_reims_cathedral_01
                }
            }
        }
    }
}

DI_tm_destroy_building_pam_reims_cathedral_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = pam_reims_cathedral_01 } remove_building = pam_reims_cathedral_01 }
            }
        }
    }
}

DI_tm_building_temple_citadel_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        NOT = { has_building_or_higher = temple_citadel_01 }
                    }
                    set_holding_type = temple_citadel_holding
                }
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = temple_citadel_01 }
                    }
                    add_building = temple_citadel_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = temple_citadel_02 }
                    }
                    add_building = temple_citadel_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = temple_citadel_03 }
                    }
                    add_building = temple_citadel_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = temple_citadel_04 }
                    }
                    add_building = temple_citadel_04
                }
            }
        }
    }
}

DI_tm_destroy_building_temple_citadel_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = temple_citadel_04 } remove_building = temple_citadel_04 }
                else_if = { limit = { has_building = temple_citadel_03 } remove_building = temple_citadel_03 }
                else_if = { limit = { has_building = temple_citadel_02 } remove_building = temple_citadel_02 }
                else_if = { limit = { has_building = temple_citadel_01 } remove_building = temple_citadel_01 }
            }
        }
    }
}

DI_tm_building_citadel_shrine_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = citadel_shrine_01 }
                    }
                    add_building = citadel_shrine_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = citadel_shrine_02 }
                    }
                    add_building = citadel_shrine_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = citadel_shrine_03 }
                    }
                    add_building = citadel_shrine_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = citadel_shrine_04 }
                    }
                    add_building = citadel_shrine_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = citadel_shrine_05 }
                    }
                    add_building = citadel_shrine_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = citadel_shrine_06 }
                    }
                    add_building = citadel_shrine_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = citadel_shrine_07 }
                    }
                    add_building = citadel_shrine_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = citadel_shrine_08 }
                    }
                    add_building = citadel_shrine_08
                }
            }
        }
    }
}

DI_tm_destroy_building_citadel_shrine_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = citadel_shrine }
            }
        }
    }
}

DI_tm_building_sacred_pool_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = sacred_pool_01 }
                    }
                    add_building = sacred_pool_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = sacred_pool_02 }
                    }
                    add_building = sacred_pool_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = sacred_pool_03 }
                    }
                    add_building = sacred_pool_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = sacred_pool_04 }
                    }
                    add_building = sacred_pool_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = sacred_pool_05 }
                    }
                    add_building = sacred_pool_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = sacred_pool_06 }
                    }
                    add_building = sacred_pool_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = sacred_pool_07 }
                    }
                    add_building = sacred_pool_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = sacred_pool_08 }
                    }
                    add_building = sacred_pool_08
                }
            }
        }
    }
}

DI_tm_destroy_building_sacred_pool_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = sacred_pool }
            }
        }
    }
}

DI_tm_building_vihara_halls_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
            var:DI_title_manager_building_level = 6
            var:DI_title_manager_building_level = 7
            var:DI_title_manager_building_level = 8
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = vihara_halls_01 }
                    }
                    add_building = vihara_halls_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = vihara_halls_02 }
                    }
                    add_building = vihara_halls_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = vihara_halls_03 }
                    }
                    add_building = vihara_halls_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = vihara_halls_04 }
                    }
                    add_building = vihara_halls_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = vihara_halls_05 }
                    }
                    add_building = vihara_halls_05
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 6 }
                        NOT = { has_building = vihara_halls_06 }
                    }
                    add_building = vihara_halls_06
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 7 }
                        NOT = { has_building = vihara_halls_07 }
                    }
                    add_building = vihara_halls_07
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 8 }
                        NOT = { has_building = vihara_halls_08 }
                    }
                    add_building = vihara_halls_08
                }
            }
        }
    }
}

DI_tm_destroy_building_vihara_halls_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                DI_remove_building_type_effect = { BUILDING = vihara_halls }
            }
        }
    }
}

DI_tm_building_mandala_capital_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
            var:DI_title_manager_building_level = 5
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = mandala_capital_01 }
                    }
                    add_building = mandala_capital_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = mandala_capital_02 }
                    }
                    add_building = mandala_capital_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = mandala_capital_03 }
                    }
                    add_building = mandala_capital_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = mandala_capital_04 }
                    }
                    add_building = mandala_capital_04
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 5 }
                        NOT = { has_building = mandala_capital_05 }
                    }
                    add_building = mandala_capital_05
                }
            }
        }
    }
}

DI_tm_destroy_building_mandala_capital_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = mandala_capital_05 } remove_building = mandala_capital_05 }
                else_if = { limit = { has_building = mandala_capital_04 } remove_building = mandala_capital_04 }
                else_if = { limit = { has_building = mandala_capital_03 } remove_building = mandala_capital_03 }
                else_if = { limit = { has_building = mandala_capital_02 } remove_building = mandala_capital_02 }
                else_if = { limit = { has_building = mandala_capital_01 } remove_building = mandala_capital_01 }
            }
        }
    }
}

DI_tm_building_celestial_great_barracks_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = celestial_great_barracks_01 }
                    }
                    add_building = celestial_great_barracks_01
                }
            }
        }
    }
}

DI_tm_destroy_building_celestial_great_barracks_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = celestial_great_barracks_01 } remove_building = celestial_great_barracks_01 }
            }
        }
    }
}

DI_tm_building_the_great_wall_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
            var:DI_title_manager_building_level = 2
            var:DI_title_manager_building_level = 3
            var:DI_title_manager_building_level = 4
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_great_wall_01 }
                    }
                    add_building = the_great_wall_01
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 2 }
                        NOT = { has_building = the_great_wall_02 }
                    }
                    add_building = the_great_wall_02
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 3 }
                        NOT = { has_building = the_great_wall_03 }
                    }
                    add_building = the_great_wall_03
                }
                else_if = {
                    limit = {
                        scope:player = { var:DI_title_manager_building_level = 4 }
                        NOT = { has_building = the_great_wall_04 }
                    }
                    add_building = the_great_wall_04
                }
            }
        }
    }
}

DI_tm_destroy_building_the_great_wall_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_great_wall_04 } remove_building = the_great_wall_04 }
                else_if = { limit = { has_building = the_great_wall_03 } remove_building = the_great_wall_03 }
                else_if = { limit = { has_building = the_great_wall_02 } remove_building = the_great_wall_02 }
                else_if = { limit = { has_building = the_great_wall_01 } remove_building = the_great_wall_01 }
            }
        }
    }
}

DI_tm_building_the_great_wall_shanhai_pass_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_great_wall_shanhai_pass }
                    }
                    add_building = the_great_wall_shanhai_pass
                }
            }
        }
    }
}

DI_tm_destroy_building_the_great_wall_shanhai_pass_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_great_wall_shanhai_pass } remove_building = the_great_wall_shanhai_pass }
            }
        }
    }
}

DI_tm_building_the_great_wall_liaodong_sgui = {
    scope = character # Player Character

    is_valid = {
        OR = {
            NOT = { has_variable = DI_title_manager_building_level }
            var:DI_title_manager_building_level = 1
        }
    }

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        OR = {
                            NOT = { scope:player = { has_variable = DI_title_manager_building_level } }
                            scope:player = { var:DI_title_manager_building_level = 1 }
                        }
                        NOT = { has_building = the_great_wall_liaodong }
                    }
                    add_building = the_great_wall_liaodong
                }
            }
        }
    }
}

DI_tm_destroy_building_the_great_wall_liaodong_sgui = {
    scope = character # Player Character

    effect = {
        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building = the_great_wall_liaodong } remove_building = the_great_wall_liaodong }
            }
        }
    }
}

DI_remove_buildings_sgui = {
    scope = character # Player Character

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = { limit = { has_building_or_higher = castle_02 } add_building = castle_01 }
                if = { limit = { has_building_or_higher = castle_03 } add_building = castle_01 }
                if = { limit = { has_building_or_higher = castle_04 } add_building = castle_01 }
                if = { limit = { has_building_or_higher = city_02 } add_building = city_01 }
                if = { limit = { has_building_or_higher = city_03 } add_building = city_01 }
                if = { limit = { has_building_or_higher = city_04 } add_building = city_01 }
                if = { limit = { has_building_or_higher = temple_02 } add_building = temple_01 }
                if = { limit = { has_building_or_higher = temple_03 } add_building = temple_01 }
                if = { limit = { has_building_or_higher = temple_04 } add_building = temple_01 }
                if = { limit = { has_building_or_higher = temple_citadel_02 } add_building = temple_citadel_01 }
                if = { limit = { has_building_or_higher = temple_citadel_03 } add_building = temple_citadel_01 }
                if = { limit = { has_building_or_higher = temple_citadel_04 } add_building = temple_citadel_01 }
                if = { limit = { has_building_or_higher = tribe_02 } add_building = tribe_01 }

                if = { limit = { has_building = al_azhar_university } remove_building = al_azhar_university }
                if = { limit = { has_building = al_qarawiyyin_university_01 } remove_building = al_qarawiyyin_university_01 }
                if = { limit = { has_building = alamut_castle_02 } remove_building = alamut_castle_02 }
                else_if = { limit = { has_building = alamut_castle_01 } remove_building = alamut_castle_01 }
                if = { limit = { has_building = alcazar_of_segovia_01 } remove_building = alcazar_of_segovia_01 }
                if = { limit = { has_building = alhambra_02 } remove_building = alhambra_02 }
                else_if = { limit = { has_building = alhambra_01 } remove_building = alhambra_01 }
                if = { limit = { has_building = aljaferia_palace_01 } remove_building = aljaferia_palace_01 }
                if = { limit = { has_building = allaq_mines_04 } remove_building = allaq_mines_04 }
                else_if = { limit = { has_building = allaq_mines_03 } remove_building = allaq_mines_03 }
                else_if = { limit = { has_building = allaq_mines_02 } remove_building = allaq_mines_02 }
                else_if = { limit = { has_building = allaq_mines_01 } remove_building = allaq_mines_01 }
                if = { limit = { has_building = ananda_temple_01 } remove_building = ananda_temple_01 }
                if = { limit = { has_building = angkor_wat_01 } remove_building = angkor_wat_01 }
                if = { limit = { has_building = apollinare_nuovo } remove_building = apollinare_nuovo }
                if = { limit = { has_building = archery_ranges_03 } remove_building = archery_ranges_03 }
                else_if = { limit = { has_building = archery_ranges_02 } remove_building = archery_ranges_02 }
                else_if = { limit = { has_building = archery_ranges_01 } remove_building = archery_ranges_01 }
                if = { limit = { has_building = argentiera_mines_04 } remove_building = argentiera_mines_04 }
                else_if = { limit = { has_building = argentiera_mines_03 } remove_building = argentiera_mines_03 }
                else_if = { limit = { has_building = argentiera_mines_02 } remove_building = argentiera_mines_02 }
                else_if = { limit = { has_building = argentiera_mines_01 } remove_building = argentiera_mines_01 }
                if = { limit = { has_building = ark_of_bukhara_01 } remove_building = ark_of_bukhara_01 }
                if = { limit = { has_building = assassin_castle_01 } remove_building = assassin_castle_01 }
                if = { limit = { has_building = aurelian_walls_01 } remove_building = aurelian_walls_01 }
                if = { limit = { has_building = baofeng_mines_04 } remove_building = baofeng_mines_04 }
                else_if = { limit = { has_building = baofeng_mines_03 } remove_building = baofeng_mines_03 }
                else_if = { limit = { has_building = baofeng_mines_02 } remove_building = baofeng_mines_02 }
                else_if = { limit = { has_building = baofeng_mines_01 } remove_building = baofeng_mines_01 }
                DI_remove_building_type_effect = { BUILDING = barracks }
                if = { limit = { has_building = besakih_temple_01 } remove_building = besakih_temple_01 }
                if = { limit = { has_building = beta_giyorgis_01 } remove_building = beta_giyorgis_01 }
                if = { limit = { has_building = blacksmiths_03 } remove_building = blacksmiths_03 }
                else_if = { limit = { has_building = blacksmiths_02 } remove_building = blacksmiths_02 }
                else_if = { limit = { has_building = blacksmiths_01 } remove_building = blacksmiths_01 }
                if = { limit = { has_building = borobudur_01 } remove_building = borobudur_01 }
                if = { limit = { has_building = boudhanath_01 } remove_building = boudhanath_01 }
                DI_remove_building_type_effect = { BUILDING = breweries }
                if = { limit = { has_building = brihadeeswarar_temple_01 } remove_building = brihadeeswarar_temple_01 }
                if = { limit = { has_building = buddha_kamakura_01 } remove_building = buddha_kamakura_01 }
                if = { limit = { has_building = buddhas_of_bamian_01 } remove_building = buddhas_of_bamian_01 }
                if = { limit = { has_building = burial_site_03 } remove_building = burial_site_03 }
                else_if = { limit = { has_building = burial_site_02 } remove_building = burial_site_02 }
                else_if = { limit = { has_building = burial_site_01 } remove_building = burial_site_01 }
                if = { limit = { has_building = burkhan_khaldun_01 } remove_building = burkhan_khaldun_01 }
                if = { limit = { has_building = byeokran_port_01 } remove_building = byeokran_port_01 }
                DI_remove_building_type_effect = { BUILDING = camel_farms }
                DI_remove_building_type_effect = { BUILDING = capital_bureau }
                DI_remove_building_type_effect = { BUILDING = caravanserai }
                if = { limit = { has_building = cattolica_stilo } remove_building = cattolica_stilo }
                if = { limit = { has_building = celestial_great_barracks_01 } remove_building = celestial_great_barracks_01 }
                DI_remove_building_type_effect = { BUILDING = cereal_fields }
                if = { limit = { has_building = cevennes_mines_04 } remove_building = cevennes_mines_04 }
                else_if = { limit = { has_building = cevennes_mines_03 } remove_building = cevennes_mines_03 }
                else_if = { limit = { has_building = cevennes_mines_02 } remove_building = cevennes_mines_02 }
                else_if = { limit = { has_building = cevennes_mines_01 } remove_building = cevennes_mines_01 }
                if = { limit = { has_building = changan_market_02 } remove_building = changan_market_02 }
                else_if = { limit = { has_building = changan_market_01 } remove_building = changan_market_01 }
                if = { limit = { has_building = charnel_grounds_03 } remove_building = charnel_grounds_03 }
                else_if = { limit = { has_building = charnel_grounds_02 } remove_building = charnel_grounds_02 }
                else_if = { limit = { has_building = charnel_grounds_01 } remove_building = charnel_grounds_01 }
                if = { limit = { has_building = chihu_mines_04 } remove_building = chihu_mines_04 }
                else_if = { limit = { has_building = chihu_mines_03 } remove_building = chihu_mines_03 }
                else_if = { limit = { has_building = chihu_mines_02 } remove_building = chihu_mines_02 }
                else_if = { limit = { has_building = chihu_mines_01 } remove_building = chihu_mines_01 }
                if = { limit = { has_building = chinjufu_01 } remove_building = chinjufu_01 }
                if = { limit = { has_building = chocolate_hills_01 } remove_building = chocolate_hills_01 }
                if = { limit = { has_building = parthenon } remove_building = parthenon }
                else_if = { limit = { has_building = church_of_the_theotokos } remove_building = church_of_the_theotokos }
                if = { limit = { has_building = cilician_gates } remove_building = cilician_gates }
                if = { limit = { has_building = citadel_linan_01 } remove_building = citadel_linan_01 }
                if = { limit = { has_building = citadel_of_aleppo_02 } remove_building = citadel_of_aleppo_02 }
                else_if = { limit = { has_building = citadel_of_aleppo_01 } remove_building = citadel_of_aleppo_01 }
                DI_remove_building_type_effect = { BUILDING = citadel_shrine }
                if = { limit = { has_building = citadel_thang_long_02 } remove_building = citadel_thang_long_02 }
                else_if = { limit = { has_building = citadel_thang_long_01 } remove_building = citadel_thang_long_01 }
                if = { limit = { has_building = city_wall_of_toledo_01 } remove_building = city_wall_of_toledo_01 }
                if = { limit = { has_building = cluny_abbey_02 } remove_building = cluny_abbey_02 }
                else_if = { limit = { has_building = cluny_abbey_01 } remove_building = cluny_abbey_01 }
                DI_remove_building_type_effect = { BUILDING = common_tradeport }
                if = { limit = { has_building = confucius_temple_01 } remove_building = confucius_temple_01 }
                if = { limit = { has_building = culai_academy_01 } remove_building = culai_academy_01 }
                DI_remove_building_type_effect = { BUILDING = curtain_walls }
                if = { limit = { has_building = damascus_mosque_01 } remove_building = damascus_mosque_01 }
                if = { limit = { has_building = danevirke_01 } remove_building = danevirke_01 }
                if = { limit = { has_building = dau_temple_01 } remove_building = dau_temple_01 }
                if = { limit = { has_building = dazaifu_01 } remove_building = dazaifu_01 }
                if = { limit = { has_building = dean_mines_04 } remove_building = dean_mines_04 }
                else_if = { limit = { has_building = dean_mines_03 } remove_building = dean_mines_03 }
                else_if = { limit = { has_building = dean_mines_02 } remove_building = dean_mines_02 }
                else_if = { limit = { has_building = dean_mines_01 } remove_building = dean_mines_01 }
                if = { limit = { has_building = dengfeng_observatory_01 } remove_building = dengfeng_observatory_01 }
                if = { limit = { has_building = despot_palace } remove_building = despot_palace }
                if = { limit = { has_building = dieng_plateau_01 } remove_building = dieng_plateau_01 }
                if = { limit = { has_building = doges_palace_01 } remove_building = doges_palace_01 }
                if = { limit = { has_building = temple_in_jerusalem_01 } remove_building = temple_in_jerusalem_01 }
                else_if = { limit = { has_building = dome_of_the_rock_01 } remove_building = dome_of_the_rock_01 }
                if = { limit = { has_building = dragon_kiln_03 } remove_building = dragon_kiln_03 }
                else_if = { limit = { has_building = dragon_kiln_02 } remove_building = dragon_kiln_02 }
                else_if = { limit = { has_building = dragon_kiln_01 } remove_building = dragon_kiln_01 }
                if = { limit = { has_building = drassanes_01 } remove_building = drassanes_01 }
                if = { limit = { has_building = dunhuang_market_02 } remove_building = dunhuang_market_02 }
                else_if = { limit = { has_building = dunhuang_market_01 } remove_building = dunhuang_market_01 }
                if = { limit = { has_building = duomo_florence_04 } remove_building = duomo_florence_04 }
                else_if = { limit = { has_building = duomo_florence_03 } remove_building = duomo_florence_03 }
                else_if = { limit = { has_building = duomo_florence_02 } remove_building = duomo_florence_02 }
                else_if = { limit = { has_building = duomo_florence_01 } remove_building = duomo_florence_01 }
                if = { limit = { has_building = dushan_mines_04 } remove_building = dushan_mines_04 }
                else_if = { limit = { has_building = dushan_mines_03 } remove_building = dushan_mines_03 }
                else_if = { limit = { has_building = dushan_mines_02 } remove_building = dushan_mines_02 }
                else_if = { limit = { has_building = dushan_mines_01 } remove_building = dushan_mines_01 }
                if = { limit = { has_building = dvin_shuka_02 } remove_building = dvin_shuka_02 }
                else_if = { limit = { has_building = dvin_shuka_01 } remove_building = dvin_shuka_01 }
                DI_remove_building_type_effect = { BUILDING = elephant_pens }
                if = { limit = { has_building = enryaku_ji_01 } remove_building = enryaku_ji_01 }
                if = { limit = { has_building = etchmiadzin_cathedral } remove_building = etchmiadzin_cathedral }
                if = { limit = { has_building = event_tower_of_silence_01 } remove_building = event_tower_of_silence_01 }
                if = { limit = { has_building = examination_hall_03 } remove_building = examination_hall_03 }
                else_if = { limit = { has_building = examination_hall_02 } remove_building = examination_hall_02 }
                else_if = { limit = { has_building = examination_hall_01 } remove_building = examination_hall_01 }
                if = { limit = { has_building = fairy_chimneys } remove_building = fairy_chimneys }
                if = { limit = { has_building = falak_ol_aflak_citadel_01 } remove_building = falak_ol_aflak_citadel_01 }
                if = { limit = { has_building = falun_mines_04 } remove_building = falun_mines_04 }
                else_if = { limit = { has_building = falun_mines_03 } remove_building = falun_mines_03 }
                else_if = { limit = { has_building = falun_mines_02 } remove_building = falun_mines_02 }
                else_if = { limit = { has_building = falun_mines_01 } remove_building = falun_mines_01 }
                if = { limit = { has_building = fanfang_guangzhou_01 } remove_building = fanfang_guangzhou_01 }
                DI_remove_building_type_effect = { BUILDING = farm_estates }
                if = { limit = { has_building = fengtian_mines_03 } remove_building = fengtian_mines_03 }
                else_if = { limit = { has_building = fengtian_mines_02 } remove_building = fengtian_mines_02 }
                else_if = { limit = { has_building = fengtian_mines_01 } remove_building = fengtian_mines_01 }
                if = { limit = { has_building = forbidden_city_01 } remove_building = forbidden_city_01 }
                if = { limit = { has_building = generic_copper_mines_04 } remove_building = generic_copper_mines_04 }
                else_if = { limit = { has_building = generic_copper_mines_03 } remove_building = generic_copper_mines_03 }
                else_if = { limit = { has_building = generic_copper_mines_02 } remove_building = generic_copper_mines_02 }
                else_if = { limit = { has_building = generic_copper_mines_01 } remove_building = generic_copper_mines_01 }
                if = { limit = { has_building = generic_gold_mines_04 } remove_building = generic_gold_mines_04 }
                else_if = { limit = { has_building = generic_gold_mines_03 } remove_building = generic_gold_mines_03 }
                else_if = { limit = { has_building = generic_gold_mines_02 } remove_building = generic_gold_mines_02 }
                else_if = { limit = { has_building = generic_gold_mines_01 } remove_building = generic_gold_mines_01 }
                if = { limit = { has_building = generic_silver_mines_04 } remove_building = generic_silver_mines_04 }
                else_if = { limit = { has_building = generic_silver_mines_03 } remove_building = generic_silver_mines_03 }
                else_if = { limit = { has_building = generic_silver_mines_02 } remove_building = generic_silver_mines_02 }
                else_if = { limit = { has_building = generic_silver_mines_01 } remove_building = generic_silver_mines_01 }
                if = { limit = { has_building = generic_university } remove_building = generic_university }
                if = { limit = { has_building = ghana_palace_01 } remove_building = ghana_palace_01 }
                if = { limit = { has_building = giant_wild_goose_pagoda_01 } remove_building = giant_wild_goose_pagoda_01 }
                if = { limit = { has_building = goguryeo_tomb_01 } remove_building = goguryeo_tomb_01 }
                if = { limit = { has_building = golden_gate_of_kiev_01 } remove_building = golden_gate_of_kiev_01 }
                if = { limit = { has_building = gongsanseong_fortress_01 } remove_building = gongsanseong_fortress_01 }
                if = { limit = { has_building = great_megalith_01 } remove_building = great_megalith_01 }
                if = { limit = { has_building = great_project_cathedral_03 } remove_building = great_project_cathedral_03 }
                else_if = { limit = { has_building = great_project_cathedral_02 } remove_building = great_project_cathedral_02 }
                else_if = { limit = { has_building = great_project_cathedral_01 } remove_building = great_project_cathedral_01 }
                if = { limit = { has_building = great_project_cathedral_under_construction } remove_building = great_project_cathedral_under_construction }
                if = { limit = { has_building = great_wall_of_gorgan_01 } remove_building = great_wall_of_gorgan_01 }
                DI_remove_building_type_effect = { BUILDING = guild_halls }
                if = { limit = { has_building = guiyang_mines_04 } remove_building = guiyang_mines_04 }
                else_if = { limit = { has_building = guiyang_mines_03 } remove_building = guiyang_mines_03 }
                else_if = { limit = { has_building = guiyang_mines_02 } remove_building = guiyang_mines_02 }
                else_if = { limit = { has_building = guiyang_mines_01 } remove_building = guiyang_mines_01 }
                if = { limit = { has_building = gunung_api_01 } remove_building = gunung_api_01 }
                if = { limit = { has_building = ha_long_bay_01 } remove_building = ha_long_bay_01 }
                if = { limit = { has_building = hadrians_wall_01 } remove_building = hadrians_wall_01 }
                if = { limit = { has_building = hagia_sophia_02 } remove_building = hagia_sophia_02 }
                else_if = { limit = { has_building = hagia_sophia_01 } remove_building = hagia_sophia_01 }
                if = { limit = { has_building = hagios_demetrios } remove_building = hagios_demetrios }
                if = { limit = { has_building = hakata_port_01 } remove_building = hakata_port_01 }
                if = { limit = { has_building = hall_of_heroes_05 } remove_building = hall_of_heroes_05 }
                else_if = { limit = { has_building = hall_of_heroes_04 } remove_building = hall_of_heroes_04 }
                else_if = { limit = { has_building = hall_of_heroes_03 } remove_building = hall_of_heroes_03 }
                else_if = { limit = { has_building = hall_of_heroes_02 } remove_building = hall_of_heroes_02 }
                else_if = { limit = { has_building = hall_of_heroes_01 } remove_building = hall_of_heroes_01 }
                if = { limit = { has_building = hamadan_bazaar_02 } remove_building = hamadan_bazaar_02 }
                else_if = { limit = { has_building = hamadan_bazaar_01 } remove_building = hamadan_bazaar_01 }
                if = { limit = { has_building = hanging_temple_01 } remove_building = hanging_temple_01 }
                if = { limit = { has_building = hanxing_mines_04 } remove_building = hanxing_mines_04 }
                else_if = { limit = { has_building = hanxing_mines_03 } remove_building = hanxing_mines_03 }
                else_if = { limit = { has_building = hanxing_mines_02 } remove_building = hanxing_mines_02 }
                else_if = { limit = { has_building = hanxing_mines_01 } remove_building = hanxing_mines_01 }
                if = { limit = { has_building = heddal_stave_church_01 } remove_building = heddal_stave_church_01 }
                if = { limit = { has_building = heian_palace_01 } remove_building = heian_palace_01 }
                if = { limit = { has_building = herat_bazaar_02 } remove_building = herat_bazaar_02 }
                else_if = { limit = { has_building = herat_bazaar_01 } remove_building = herat_bazaar_01 }
                if = { limit = { has_building = hetian_mines_04 } remove_building = hetian_mines_04 }
                else_if = { limit = { has_building = hetian_mines_03 } remove_building = hetian_mines_03 }
                else_if = { limit = { has_building = hetian_mines_02 } remove_building = hetian_mines_02 }
                else_if = { limit = { has_building = hetian_mines_01 } remove_building = hetian_mines_01 }
                DI_remove_building_type_effect = { BUILDING = hill_farms }
                DI_remove_building_type_effect = { BUILDING = hill_forts }
                DI_remove_building_type_effect = { BUILDING = hillside_grazing }
                if = { limit = { has_building = holy_site_basilica_santiago_01 } remove_building = holy_site_basilica_santiago_01 }
                if = { limit = { has_building = holy_site_buddhist_grand_temple_01 } remove_building = holy_site_buddhist_grand_temple_01 }
                if = { limit = { has_building = holy_site_canterbury_cathedral_03 } remove_building = holy_site_canterbury_cathedral_03 }
                else_if = { limit = { has_building = holy_site_canterbury_cathedral_02 } remove_building = holy_site_canterbury_cathedral_02 }
                else_if = { limit = { has_building = holy_site_canterbury_cathedral_01 } remove_building = holy_site_canterbury_cathedral_01 }
                if = { limit = { has_building = holy_site_cathedral_01 } remove_building = holy_site_cathedral_01 }
                if = { limit = { has_building = holy_site_chinese_temple_01 } remove_building = holy_site_chinese_temple_01 }
                if = { limit = { has_building = holy_site_cologne_cathedral_01 } remove_building = holy_site_cologne_cathedral_01 }
                if = { limit = { has_building = holy_site_fire_temple_01 } remove_building = holy_site_fire_temple_01 }
                if = { limit = { has_building = holy_site_great_mosque_of_cordoba_01 } remove_building = holy_site_great_mosque_of_cordoba_01 }
                if = { limit = { has_building = holy_site_great_mosque_of_djenne_01 } remove_building = holy_site_great_mosque_of_djenne_01 }
                if = { limit = { has_building = holy_site_great_mosque_of_mecca_01 } remove_building = holy_site_great_mosque_of_mecca_01 }
                if = { limit = { has_building = holy_site_great_mosque_of_samarra_01 } remove_building = holy_site_great_mosque_of_samarra_01 }
                if = { limit = { has_building = holy_site_imam_ali_mosque_01 } remove_building = holy_site_imam_ali_mosque_01 }
                if = { limit = { has_building = holy_site_indian_grand_temple_01 } remove_building = holy_site_indian_grand_temple_01 }
                if = { limit = { has_building = holy_site_japanese_temple_01 } remove_building = holy_site_japanese_temple_01 }
                if = { limit = { has_building = holy_site_mahabodhi_temple_01 } remove_building = holy_site_mahabodhi_temple_01 }
                if = { limit = { has_building = holy_site_mosque_01 } remove_building = holy_site_mosque_01 }
                if = { limit = { has_building = holy_site_other_grand_temple_01 } remove_building = holy_site_other_grand_temple_01 }
                if = { limit = { has_building = holy_site_pagan_grand_temple_01 } remove_building = holy_site_pagan_grand_temple_01 }
                if = { limit = { has_building = holy_site_prophetic_mosque_01 } remove_building = holy_site_prophetic_mosque_01 }
                if = { limit = { has_building = holy_site_se_asia_pagan_temple_01 } remove_building = holy_site_se_asia_pagan_temple_01 }
                if = { limit = { has_building = holy_site_st_peters_basilica_01 } remove_building = holy_site_st_peters_basilica_01 }
                if = { limit = { has_building = holy_wisdom_01 } remove_building = holy_wisdom_01 }
                DI_remove_building_type_effect = { BUILDING = horse_pastures }
                if = { limit = { has_building = hoshi_ryokan_01 } remove_building = hoshi_ryokan_01 }
                if = { limit = { has_building = hosios_loukas } remove_building = hosios_loukas }
                DI_remove_building_type_effect = { BUILDING = hospices }
                if = { limit = { has_building = hotin_fort_02 } remove_building = hotin_fort_02 }
                else_if = { limit = { has_building = hotin_fort_01 } remove_building = hotin_fort_01 }
                if = { limit = { has_building = house_of_wisdom_01 } remove_building = house_of_wisdom_01 }
                if = { limit = { has_building = hpakant_mines_04 } remove_building = hpakant_mines_04 }
                else_if = { limit = { has_building = hpakant_mines_03 } remove_building = hpakant_mines_03 }
                else_if = { limit = { has_building = hpakant_mines_02 } remove_building = hpakant_mines_02 }
                else_if = { limit = { has_building = hpakant_mines_01 } remove_building = hpakant_mines_01 }
                DI_remove_building_type_effect = { BUILDING = hunting_grounds }
                if = { limit = { has_building = hwangnyongsa_01 } remove_building = hwangnyongsa_01 }
                if = { limit = { has_building = idjang_forts_04 } remove_building = idjang_forts_04 }
                else_if = { limit = { has_building = idjang_forts_03 } remove_building = idjang_forts_03 }
                else_if = { limit = { has_building = idjang_forts_02 } remove_building = idjang_forts_02 }
                else_if = { limit = { has_building = idjang_forts_01 } remove_building = idjang_forts_01 }
                if = { limit = { has_building = ijil_mines_04 } remove_building = ijil_mines_04 }
                else_if = { limit = { has_building = ijil_mines_03 } remove_building = ijil_mines_03 }
                else_if = { limit = { has_building = ijil_mines_02 } remove_building = ijil_mines_02 }
                else_if = { limit = { has_building = ijil_mines_01 } remove_building = ijil_mines_01 }
                if = { limit = { has_building = imam_reza_shrine_01 } remove_building = imam_reza_shrine_01 }
                if = { limit = { has_building = iron_lion_cangzhou_01 } remove_building = iron_lion_cangzhou_01 }
                if = { limit = { has_building = iron_pillar_of_delhi_01 } remove_building = iron_pillar_of_delhi_01 }
                if = { limit = { has_building = iron_pillar_of_dhar_01 } remove_building = iron_pillar_of_dhar_01 }
                if = { limit = { has_building = ise_jingu_01 } remove_building = ise_jingu_01 }
                if = { limit = { has_building = itoigawa_mines_04 } remove_building = itoigawa_mines_04 }
                else_if = { limit = { has_building = itoigawa_mines_03 } remove_building = itoigawa_mines_03 }
                else_if = { limit = { has_building = itoigawa_mines_02 } remove_building = itoigawa_mines_02 }
                else_if = { limit = { has_building = itoigawa_mines_01 } remove_building = itoigawa_mines_01 }
                if = { limit = { has_building = itsukushima_jinja_02 } remove_building = itsukushima_jinja_02 }
                else_if = { limit = { has_building = itsukushima_jinja_01 } remove_building = itsukushima_jinja_01 }
                if = { limit = { has_building = izumo_taisha_01 } remove_building = izumo_taisha_01 }
                if = { limit = { has_building = jaisalmer_fort_01 } remove_building = jaisalmer_fort_01 }
                if = { limit = { has_building = jiaodong_mines_04 } remove_building = jiaodong_mines_04 }
                else_if = { limit = { has_building = jiaodong_mines_03 } remove_building = jiaodong_mines_03 }
                else_if = { limit = { has_building = jiaodong_mines_02 } remove_building = jiaodong_mines_02 }
                else_if = { limit = { has_building = jiaodong_mines_01 } remove_building = jiaodong_mines_01 }
                if = { limit = { has_building = jizu_shan_temples_01 } remove_building = jizu_shan_temples_01 }
                if = { limit = { has_building = jokhang_01 } remove_building = jokhang_01 }
                if = { limit = { has_building = jousting_lists_03 } remove_building = jousting_lists_03 }
                else_if = { limit = { has_building = jousting_lists_02 } remove_building = jousting_lists_02 }
                else_if = { limit = { has_building = jousting_lists_01 } remove_building = jousting_lists_01 }
                if = { limit = { has_building = jvari_monastery } remove_building = jvari_monastery }
                if = { limit = { has_building = kaibao_mines_04 } remove_building = kaibao_mines_04 }
                else_if = { limit = { has_building = kaibao_mines_03 } remove_building = kaibao_mines_03 }
                else_if = { limit = { has_building = kaibao_mines_02 } remove_building = kaibao_mines_02 }
                else_if = { limit = { has_building = kaibao_mines_01 } remove_building = kaibao_mines_01 }
                if = { limit = { has_building = kaifeng_palace_01 } remove_building = kaifeng_palace_01 }
                if = { limit = { has_building = kairouan_basins_01 } remove_building = kairouan_basins_01 }
                if = { limit = { has_building = kano_walls_01 } remove_building = kano_walls_01 }
                if = { limit = { has_building = kassiopi_castle } remove_building = kassiopi_castle }
                if = { limit = { has_building = khajuraho_01 } remove_building = khajuraho_01 }
                if = { limit = { has_building = khetri_mines_04 } remove_building = khetri_mines_04 }
                else_if = { limit = { has_building = khetri_mines_03 } remove_building = khetri_mines_03 }
                else_if = { limit = { has_building = khetri_mines_02 } remove_building = khetri_mines_02 }
                else_if = { limit = { has_building = khetri_mines_01 } remove_building = khetri_mines_01 }
                if = { limit = { has_building = khiva_bazaar_02 } remove_building = khiva_bazaar_02 }
                else_if = { limit = { has_building = khiva_bazaar_01 } remove_building = khiva_bazaar_01 }
                if = { limit = { has_building = kofuku_ji_01 } remove_building = kofuku_ji_01 }
                if = { limit = { has_building = koganeyama_mines_04 } remove_building = koganeyama_mines_04 }
                else_if = { limit = { has_building = koganeyama_mines_03 } remove_building = koganeyama_mines_03 }
                else_if = { limit = { has_building = koganeyama_mines_02 } remove_building = koganeyama_mines_02 }
                else_if = { limit = { has_building = koganeyama_mines_01 } remove_building = koganeyama_mines_01 }
                if = { limit = { has_building = kollur_mines_04 } remove_building = kollur_mines_04 }
                else_if = { limit = { has_building = kollur_mines_03 } remove_building = kollur_mines_03 }
                else_if = { limit = { has_building = kollur_mines_02 } remove_building = kollur_mines_02 }
                else_if = { limit = { has_building = kollur_mines_01 } remove_building = kollur_mines_01 }
                if = { limit = { has_building = konark_temple_01 } remove_building = konark_temple_01 }
                if = { limit = { has_building = konasamudram_mines_04 } remove_building = konasamudram_mines_04 }
                else_if = { limit = { has_building = konasamudram_mines_03 } remove_building = konasamudram_mines_03 }
                else_if = { limit = { has_building = konasamudram_mines_02 } remove_building = konasamudram_mines_02 }
                else_if = { limit = { has_building = konasamudram_mines_01 } remove_building = konasamudram_mines_01 }
                if = { limit = { has_building = kora_kora_yards_04 } remove_building = kora_kora_yards_04 }
                else_if = { limit = { has_building = kora_kora_yards_03 } remove_building = kora_kora_yards_03 }
                else_if = { limit = { has_building = kora_kora_yards_02 } remove_building = kora_kora_yards_02 }
                else_if = { limit = { has_building = kora_kora_yards_01 } remove_building = kora_kora_yards_01 }
                if = { limit = { has_building = krakatoa_01 } remove_building = krakatoa_01 }
                if = { limit = { has_building = kremnica_mines_04 } remove_building = kremnica_mines_04 }
                else_if = { limit = { has_building = kremnica_mines_03 } remove_building = kremnica_mines_03 }
                else_if = { limit = { has_building = kremnica_mines_02 } remove_building = kremnica_mines_02 }
                else_if = { limit = { has_building = kremnica_mines_01 } remove_building = kremnica_mines_01 }
                if = { limit = { has_building = kutna_hora_mines_04 } remove_building = kutna_hora_mines_04 }
                else_if = { limit = { has_building = kutna_hora_mines_03 } remove_building = kutna_hora_mines_03 }
                else_if = { limit = { has_building = kutna_hora_mines_02 } remove_building = kutna_hora_mines_02 }
                else_if = { limit = { has_building = kutna_hora_mines_01 } remove_building = kutna_hora_mines_01 }
                if = { limit = { has_building = kyz_kala_01 } remove_building = kyz_kala_01 }
                if = { limit = { has_building = lahur_bazaar_02 } remove_building = lahur_bazaar_02 }
                else_if = { limit = { has_building = lahur_bazaar_01 } remove_building = lahur_bazaar_01 }
                if = { limit = { has_building = lantian_mines_04 } remove_building = lantian_mines_04 }
                else_if = { limit = { has_building = lantian_mines_03 } remove_building = lantian_mines_03 }
                else_if = { limit = { has_building = lantian_mines_02 } remove_building = lantian_mines_02 }
                else_if = { limit = { has_building = lantian_mines_01 } remove_building = lantian_mines_01 }
                if = { limit = { has_building = legendary_hunting_lodge } remove_building = legendary_hunting_lodge }
                if = { limit = { has_building = legendary_palace } remove_building = legendary_palace }
                if = { limit = { has_building = legendary_shrine } remove_building = legendary_shrine }
                if = { limit = { has_building = legendary_statue } remove_building = legendary_statue }
                if = { limit = { has_building = legendary_watchtower } remove_building = legendary_watchtower }
                if = { limit = { has_building = leisure_palace_03 } remove_building = leisure_palace_03 }
                else_if = { limit = { has_building = leisure_palace_02 } remove_building = leisure_palace_02 }
                else_if = { limit = { has_building = leisure_palace_01 } remove_building = leisure_palace_01 }
                if = { limit = { has_building = leshan_giant_buddha_01 } remove_building = leshan_giant_buddha_01 }
                if = { limit = { has_building = lhasa_market_02 } remove_building = lhasa_market_02 }
                else_if = { limit = { has_building = lhasa_market_01 } remove_building = lhasa_market_01 }
                if = { limit = { has_building = liangzhe_mines_04 } remove_building = liangzhe_mines_04 }
                else_if = { limit = { has_building = liangzhe_mines_03 } remove_building = liangzhe_mines_03 }
                else_if = { limit = { has_building = liangzhe_mines_02 } remove_building = liangzhe_mines_02 }
                else_if = { limit = { has_building = liangzhe_mines_01 } remove_building = liangzhe_mines_01 }
                if = { limit = { has_building = lingyin_temple_01 } remove_building = lingyin_temple_01 }
                if = { limit = { has_building = liuhe_pagoda_01 } remove_building = liuhe_pagoda_01 }
                if = { limit = { has_building = lize_academy_01 } remove_building = lize_academy_01 }
                DI_remove_building_type_effect = { BUILDING = logging_camps }
                if = { limit = { has_building = london_bridge_01 } remove_building = london_bridge_01 }
                if = { limit = { has_building = longhouses_02 } remove_building = longhouses_02 }
                else_if = { limit = { has_building = longhouses_01 } remove_building = longhouses_01 }
                if = { limit = { has_building = lund_cathedral_01 } remove_building = lund_cathedral_01 }
                if = { limit = { has_building = maharloo_lake_01 } remove_building = maharloo_lake_01 }
                if = { limit = { has_building = maiden_tower } remove_building = maiden_tower }
                if = { limit = { has_building = maijishan_grottoes_01 } remove_building = maijishan_grottoes_01 }
                if = { limit = { has_building = mali_mines_04 } remove_building = mali_mines_04 }
                else_if = { limit = { has_building = mali_mines_03 } remove_building = mali_mines_03 }
                else_if = { limit = { has_building = mali_mines_02 } remove_building = mali_mines_02 }
                else_if = { limit = { has_building = mali_mines_01 } remove_building = mali_mines_01 }
                if = { limit = { has_building = mandala_capital_05 } remove_building = mandala_capital_05 }
                else_if = { limit = { has_building = mandala_capital_04 } remove_building = mandala_capital_04 }
                else_if = { limit = { has_building = mandala_capital_03 } remove_building = mandala_capital_03 }
                else_if = { limit = { has_building = mandala_capital_02 } remove_building = mandala_capital_02 }
                else_if = { limit = { has_building = mandala_capital_01 } remove_building = mandala_capital_01 }
                if = { limit = { has_building = maoshan_academy_01 } remove_building = maoshan_academy_01 }
                if = { limit = { has_building = march_03 } remove_building = march_03 }
                else_if = { limit = { has_building = march_02 } remove_building = march_02 }
                else_if = { limit = { has_building = march_01 } remove_building = march_01 }
                if = { limit = { has_building = market_villages_02 } remove_building = market_villages_02 }
                else_if = { limit = { has_building = market_villages_01 } remove_building = market_villages_01 }
                DI_remove_building_type_effect = { BUILDING = megalith }
                if = { limit = { has_building = meteora_02 } remove_building = meteora_02 }
                else_if = { limit = { has_building = meteora_01 } remove_building = meteora_01 }
                if = { limit = { has_building = military_academy_03 } remove_building = military_academy_03 }
                else_if = { limit = { has_building = military_academy_02 } remove_building = military_academy_02 }
                else_if = { limit = { has_building = military_academy_01 } remove_building = military_academy_01 }
                DI_remove_building_type_effect = { BUILDING = military_camps }
                if = { limit = { has_building = minarets_and_remains_of_jam_01 } remove_building = minarets_and_remains_of_jam_01 }
                if = { limit = { has_building = mogok_mines_04 } remove_building = mogok_mines_04 }
                else_if = { limit = { has_building = mogok_mines_03 } remove_building = mogok_mines_03 }
                else_if = { limit = { has_building = mogok_mines_02 } remove_building = mogok_mines_02 }
                else_if = { limit = { has_building = mogok_mines_01 } remove_building = mogok_mines_01 }
                DI_remove_building_type_effect = { BUILDING = monastic_schools }
                if = { limit = { has_building = mont_st_michel_04 } remove_building = mont_st_michel_04 }
                else_if = { limit = { has_building = mont_st_michel_03 } remove_building = mont_st_michel_03 }
                else_if = { limit = { has_building = mont_st_michel_02 } remove_building = mont_st_michel_02 }
                else_if = { limit = { has_building = mont_st_michel_01 } remove_building = mont_st_michel_01 }
                if = { limit = { has_building = mount_apo_01 } remove_building = mount_apo_01 }
                if = { limit = { has_building = mount_athos_03 } remove_building = mount_athos_03 }
                else_if = { limit = { has_building = mount_athos_02 } remove_building = mount_athos_02 }
                else_if = { limit = { has_building = mount_athos_01 } remove_building = mount_athos_01 }
                if = { limit = { has_building = mount_baekdu_01 } remove_building = mount_baekdu_01 }
                if = { limit = { has_building = mount_damavand_01 } remove_building = mount_damavand_01 }
                if = { limit = { has_building = mount_fuji_01 } remove_building = mount_fuji_01 }
                if = { limit = { has_building = mozu_tombs } remove_building = mozu_tombs }
                if = { limit = { has_building = muara_takus_01 } remove_building = muara_takus_01 }
                if = { limit = { has_building = muaro_jambi_01 } remove_building = muaro_jambi_01 }
                DI_remove_building_type_effect = { BUILDING = murex_farm }
                if = { limit = { has_building = my_son_sanctuary_01 } remove_building = my_son_sanctuary_01 }
                if = { limit = { has_building = nalanda_university } remove_building = nalanda_university }
                if = { limit = { has_building = nanhua_temple_01 } remove_building = nanhua_temple_01 }
                if = { limit = { has_building = nishapur_mines_04 } remove_building = nishapur_mines_04 }
                else_if = { limit = { has_building = nishapur_mines_03 } remove_building = nishapur_mines_03 }
                else_if = { limit = { has_building = nishapur_mines_02 } remove_building = nishapur_mines_02 }
                else_if = { limit = { has_building = nishapur_mines_01 } remove_building = nishapur_mines_01 }
                if = { limit = { has_building = notre_dame_01 } remove_building = notre_dame_01 }
                if = { limit = { has_building = oath_faithful_building_04 } remove_building = oath_faithful_building_04 }
                else_if = { limit = { has_building = oath_faithful_building_03 } remove_building = oath_faithful_building_03 }
                else_if = { limit = { has_building = oath_faithful_building_02 } remove_building = oath_faithful_building_02 }
                else_if = { limit = { has_building = oath_faithful_building_01 } remove_building = oath_faithful_building_01 }
                if = { limit = { has_building = oath_poor_building_04 } remove_building = oath_poor_building_04 }
                else_if = { limit = { has_building = oath_poor_building_03 } remove_building = oath_poor_building_03 }
                else_if = { limit = { has_building = oath_poor_building_02 } remove_building = oath_poor_building_02 }
                else_if = { limit = { has_building = oath_poor_building_01 } remove_building = oath_poor_building_01 }
                if = { limit = { has_building = oath_warriors_building_04 } remove_building = oath_warriors_building_04 }
                else_if = { limit = { has_building = oath_warriors_building_03 } remove_building = oath_warriors_building_03 }
                else_if = { limit = { has_building = oath_warriors_building_02 } remove_building = oath_warriors_building_02 }
                else_if = { limit = { has_building = oath_warriors_building_01 } remove_building = oath_warriors_building_01 }
                if = { limit = { has_building = offas_dyke_01 } remove_building = offas_dyke_01 }
                DI_remove_building_type_effect = { BUILDING = orchards }
                DI_remove_building_type_effect = { BUILDING = outposts }
                DI_remove_building_type_effect = { BUILDING = paddy_fields }
                if = { limit = { has_building = pagoda_of_fogong_temple_01 } remove_building = pagoda_of_fogong_temple_01 }
                if = { limit = { has_building = palace_of_aachen_01 } remove_building = palace_of_aachen_01 }
                if = { limit = { has_building = palace_of_ctesiphon_02 } remove_building = palace_of_ctesiphon_02 }
                else_if = { limit = { has_building = palace_of_ctesiphon_01 } remove_building = palace_of_ctesiphon_01 }
                if = { limit = { has_building = palisades_02 } remove_building = palisades_02 }
                else_if = { limit = { has_building = palisades_01 } remove_building = palisades_01 }
                if = { limit = { has_building = pam_abbey_of_st_gall_01 } remove_building = pam_abbey_of_st_gall_01 }
                if = { limit = { has_building = pam_lateran_basilica_01 } remove_building = pam_lateran_basilica_01 }
                if = { limit = { has_building = pam_palais_de_papes_01 } remove_building = pam_palais_de_papes_01 }
                if = { limit = { has_building = pam_reims_cathedral_01 } remove_building = pam_reims_cathedral_01 }
                if = { limit = { has_building = pansjhir_mines_04 } remove_building = pansjhir_mines_04 }
                else_if = { limit = { has_building = pansjhir_mines_03 } remove_building = pansjhir_mines_03 }
                else_if = { limit = { has_building = pansjhir_mines_02 } remove_building = pansjhir_mines_02 }
                else_if = { limit = { has_building = pansjhir_mines_01 } remove_building = pansjhir_mines_01 }
                DI_remove_building_type_effect = { BUILDING = pastures }
                if = { limit = { has_building = patras_castle } remove_building = patras_castle }
                DI_remove_building_type_effect = { BUILDING = peat_quarries }
                if = { limit = { has_building = petra_01 } remove_building = petra_01 }
                if = { limit = { has_building = phnom_dek_mines_04 } remove_building = phnom_dek_mines_04 }
                else_if = { limit = { has_building = phnom_dek_mines_03 } remove_building = phnom_dek_mines_03 }
                else_if = { limit = { has_building = phnom_dek_mines_02 } remove_building = phnom_dek_mines_02 }
                else_if = { limit = { has_building = phnom_dek_mines_01 } remove_building = phnom_dek_mines_01 }
                if = { limit = { has_building = phocaea_mines_04 } remove_building = phocaea_mines_04 }
                else_if = { limit = { has_building = phocaea_mines_03 } remove_building = phocaea_mines_03 }
                else_if = { limit = { has_building = phocaea_mines_02 } remove_building = phocaea_mines_02 }
                else_if = { limit = { has_building = phocaea_mines_01 } remove_building = phocaea_mines_01 }
                if = { limit = { has_building = plain_of_jars_01 } remove_building = plain_of_jars_01 }
                DI_remove_building_type_effect = { BUILDING = plantations }
                if = { limit = { has_building = pleasure_dome } remove_building = pleasure_dome }
                if = { limit = { has_building = po_klong_garai_01 } remove_building = po_klong_garai_01 }
                DI_remove_building_type_effect = { BUILDING = powder_magazine }
                if = { limit = { has_building = pyramid_lingapura_01 } remove_building = pyramid_lingapura_01 }
                DI_remove_building_type_effect = { BUILDING = qanats }
                if = { limit = { has_building = qianling_mausoleum_01 } remove_building = qianling_mausoleum_01 }
                if = { limit = { has_building = quanzhou_seaport_01 } remove_building = quanzhou_seaport_01 }
                DI_remove_building_type_effect = { BUILDING = quarries }
                if = { limit = { has_building = qutb_minar_04 } remove_building = qutb_minar_04 }
                else_if = { limit = { has_building = qutb_minar_03 } remove_building = qutb_minar_03 }
                else_if = { limit = { has_building = qutb_minar_02 } remove_building = qutb_minar_02 }
                else_if = { limit = { has_building = qutb_minar_01 } remove_building = qutb_minar_01 }
                if = { limit = { has_building = rainbow_mountains_01 } remove_building = rainbow_mountains_01 }
                if = { limit = { has_building = rammelsberg_mines_04 } remove_building = rammelsberg_mines_04 }
                else_if = { limit = { has_building = rammelsberg_mines_03 } remove_building = rammelsberg_mines_03 }
                else_if = { limit = { has_building = rammelsberg_mines_02 } remove_building = rammelsberg_mines_02 }
                else_if = { limit = { has_building = rammelsberg_mines_01 } remove_building = rammelsberg_mines_01 }
                DI_remove_building_type_effect = { BUILDING = ramparts }
                if = { limit = { has_building = ratnapura_mines_04 } remove_building = ratnapura_mines_04 }
                else_if = { limit = { has_building = ratnapura_mines_03 } remove_building = ratnapura_mines_03 }
                else_if = { limit = { has_building = ratnapura_mines_02 } remove_building = ratnapura_mines_02 }
                else_if = { limit = { has_building = ratnapura_mines_01 } remove_building = ratnapura_mines_01 }
                DI_remove_building_type_effect = { BUILDING = regimental_grounds }
                if = { limit = { has_building = rock_of_gibraltar_01 } remove_building = rock_of_gibraltar_01 }
                if = { limit = { has_building = roman_wall_of_lugo_01 } remove_building = roman_wall_of_lugo_01 }
                if = { limit = { has_building = royal_armory_03 } remove_building = royal_armory_03 }
                else_if = { limit = { has_building = royal_armory_02 } remove_building = royal_armory_02 }
                else_if = { limit = { has_building = royal_armory_01 } remove_building = royal_armory_01 }
                if = { limit = { has_building = royal_forest_03 } remove_building = royal_forest_03 }
                else_if = { limit = { has_building = royal_forest_02 } remove_building = royal_forest_02 }
                else_if = { limit = { has_building = royal_forest_01 } remove_building = royal_forest_01 }
                if = { limit = { has_building = royal_garden_03 } remove_building = royal_garden_03 }
                else_if = { limit = { has_building = royal_garden_02 } remove_building = royal_garden_02 }
                else_if = { limit = { has_building = royal_garden_01 } remove_building = royal_garden_01 }
                if = { limit = { has_building = rudnik_mines_04 } remove_building = rudnik_mines_04 }
                else_if = { limit = { has_building = rudnik_mines_03 } remove_building = rudnik_mines_03 }
                else_if = { limit = { has_building = rudnik_mines_02 } remove_building = rudnik_mines_02 }
                else_if = { limit = { has_building = rudnik_mines_01 } remove_building = rudnik_mines_01 }
                DI_remove_building_type_effect = { BUILDING = sacred_pool }
                if = { limit = { has_building = sado_mines_04 } remove_building = sado_mines_04 }
                else_if = { limit = { has_building = sado_mines_03 } remove_building = sado_mines_03 }
                else_if = { limit = { has_building = sado_mines_02 } remove_building = sado_mines_02 }
                else_if = { limit = { has_building = sado_mines_01 } remove_building = sado_mines_01 }
                if = { limit = { has_building = saint_catherine } remove_building = saint_catherine }
                if = { limit = { has_building = saint_lazarus } remove_building = saint_lazarus }
                if = { limit = { has_building = sanchi_stupa_01 } remove_building = sanchi_stupa_01 }
                if = { limit = { has_building = sankore_university } remove_building = sankore_university }
                if = { limit = { has_building = sar_i_sang_mines_04 } remove_building = sar_i_sang_mines_04 }
                else_if = { limit = { has_building = sar_i_sang_mines_03 } remove_building = sar_i_sang_mines_03 }
                else_if = { limit = { has_building = sar_i_sang_mines_02 } remove_building = sar_i_sang_mines_02 }
                else_if = { limit = { has_building = sar_i_sang_mines_01 } remove_building = sar_i_sang_mines_01 }
                if = { limit = { has_building = schwaz_mines_04 } remove_building = schwaz_mines_04 }
                else_if = { limit = { has_building = schwaz_mines_03 } remove_building = schwaz_mines_03 }
                else_if = { limit = { has_building = schwaz_mines_02 } remove_building = schwaz_mines_02 }
                else_if = { limit = { has_building = schwaz_mines_01 } remove_building = schwaz_mines_01 }
                DI_remove_building_type_effect = { BUILDING = scriptorium }
                if = { limit = { has_building = shah_i_zinda_02 } remove_building = shah_i_zinda_02 }
                else_if = { limit = { has_building = shah_i_zinda_01 } remove_building = shah_i_zinda_01 }
                if = { limit = { has_building = shaolin_monastery_01 } remove_building = shaolin_monastery_01 }
                if = { limit = { has_building = shigu_academy_01 } remove_building = shigu_academy_01 }
                if = { limit = { has_building = shwedagon_pagoda_01 } remove_building = shwedagon_pagoda_01 }
                if = { limit = { has_building = siderokausia_mines_04 } remove_building = siderokausia_mines_04 }
                else_if = { limit = { has_building = siderokausia_mines_03 } remove_building = siderokausia_mines_03 }
                else_if = { limit = { has_building = siderokausia_mines_02 } remove_building = siderokausia_mines_02 }
                else_if = { limit = { has_building = siderokausia_mines_01 } remove_building = siderokausia_mines_01 }
                if = { limit = { has_building = siege_works_03 } remove_building = siege_works_03 }
                else_if = { limit = { has_building = siege_works_02 } remove_building = siege_works_02 }
                else_if = { limit = { has_building = siege_works_01 } remove_building = siege_works_01 }
                if = { limit = { has_building = siena_university } remove_building = siena_university }
                DI_remove_building_type_effect = { BUILDING = smiths }
                if = { limit = { has_building = sofia_ohrid } remove_building = sofia_ohrid }
                if = { limit = { has_building = soltaniyeh_01 } remove_building = soltaniyeh_01 }
                if = { limit = { has_building = somapura_university_01 } remove_building = somapura_university_01 }
                if = { limit = { has_building = special_greenhouse_01 } remove_building = special_greenhouse_01 }
                if = { limit = { has_building = special_sicilian_parliament_01 } remove_building = special_sicilian_parliament_01 }
                DI_remove_building_type_effect = { BUILDING = spice_plantation }
                if = { limit = { has_building = srebrenica_mines_04 } remove_building = srebrenica_mines_04 }
                else_if = { limit = { has_building = srebrenica_mines_03 } remove_building = srebrenica_mines_03 }
                else_if = { limit = { has_building = srebrenica_mines_02 } remove_building = srebrenica_mines_02 }
                else_if = { limit = { has_building = srebrenica_mines_01 } remove_building = srebrenica_mines_01 }
                DI_remove_building_type_effect = { BUILDING = stables }
                if = { limit = { has_building = stilted_granaries_04 } remove_building = stilted_granaries_04 }
                else_if = { limit = { has_building = stilted_granaries_03 } remove_building = stilted_granaries_03 }
                else_if = { limit = { has_building = stilted_granaries_02 } remove_building = stilted_granaries_02 }
                else_if = { limit = { has_building = stilted_granaries_01 } remove_building = stilted_granaries_01 }
                if = { limit = { has_building = stone_pagoda_01 } remove_building = stone_pagoda_01 }
                if = { limit = { has_building = stonehenge_01 } remove_building = stonehenge_01 }
                if = { limit = { has_building = sumela_monastery_02 } remove_building = sumela_monastery_02 }
                else_if = { limit = { has_building = sumela_monastery_01 } remove_building = sumela_monastery_01 }
                if = { limit = { has_building = sunday_bazaar_02 } remove_building = sunday_bazaar_02 }
                else_if = { limit = { has_building = sunday_bazaar_01 } remove_building = sunday_bazaar_01 }
                if = { limit = { has_building = suvarnadvipa_mines_04 } remove_building = suvarnadvipa_mines_04 }
                else_if = { limit = { has_building = suvarnadvipa_mines_03 } remove_building = suvarnadvipa_mines_03 }
                else_if = { limit = { has_building = suvarnadvipa_mines_02 } remove_building = suvarnadvipa_mines_02 }
                else_if = { limit = { has_building = suvarnadvipa_mines_01 } remove_building = suvarnadvipa_mines_01 }
                if = { limit = { has_building = suwalesi_megaliths_01 } remove_building = suwalesi_megaliths_01 }
                if = { limit = { has_building = swahili_port_lamu } remove_building = swahili_port_lamu }
                if = { limit = { has_building = swahili_port_mombasa } remove_building = swahili_port_mombasa }
                if = { limit = { has_building = swahili_port_pate } remove_building = swahili_port_pate }
                if = { limit = { has_building = swahili_port_pemba } remove_building = swahili_port_pemba }
                if = { limit = { has_building = swahili_port_zanzibar } remove_building = swahili_port_zanzibar }
                if = { limit = { has_building = tada_mines_04 } remove_building = tada_mines_04 }
                else_if = { limit = { has_building = tada_mines_03 } remove_building = tada_mines_03 }
                else_if = { limit = { has_building = tada_mines_02 } remove_building = tada_mines_02 }
                else_if = { limit = { has_building = tada_mines_01 } remove_building = tada_mines_01 }
                if = { limit = { has_building = taghaza_mines_04 } remove_building = taghaza_mines_04 }
                else_if = { limit = { has_building = taghaza_mines_03 } remove_building = taghaza_mines_03 }
                else_if = { limit = { has_building = taghaza_mines_02 } remove_building = taghaza_mines_02 }
                else_if = { limit = { has_building = taghaza_mines_01 } remove_building = taghaza_mines_01 }
                if = { limit = { has_building = takkeda_mines_04 } remove_building = takkeda_mines_04 }
                else_if = { limit = { has_building = takkeda_mines_03 } remove_building = takkeda_mines_03 }
                else_if = { limit = { has_building = takkeda_mines_02 } remove_building = takkeda_mines_02 }
                else_if = { limit = { has_building = takkeda_mines_01 } remove_building = takkeda_mines_01 }
                if = { limit = { has_building = tax_assessor_03 } remove_building = tax_assessor_03 }
                else_if = { limit = { has_building = tax_assessor_02 } remove_building = tax_assessor_02 }
                else_if = { limit = { has_building = tax_assessor_01 } remove_building = tax_assessor_01 }
                if = { limit = { has_building = temple_of_uppsala_02 } remove_building = temple_of_uppsala_02 }
                else_if = { limit = { has_building = temple_of_uppsala_01 } remove_building = temple_of_uppsala_01 }
                if = { limit = { has_building = temples_angkor_02 } remove_building = temples_angkor_02 }
                else_if = { limit = { has_building = temples_angkor_01 } remove_building = temples_angkor_01 }
                if = { limit = { has_building = the_colosseum_01 } remove_building = the_colosseum_01 }
                if = { limit = { has_building = the_friday_mosque_01 } remove_building = the_friday_mosque_01 }
                if = { limit = { has_building = the_great_wall_04 } remove_building = the_great_wall_04 }
                else_if = { limit = { has_building = the_great_wall_03 } remove_building = the_great_wall_03 }
                else_if = { limit = { has_building = the_great_wall_02 } remove_building = the_great_wall_02 }
                else_if = { limit = { has_building = the_great_wall_01 } remove_building = the_great_wall_01 }
                if = { limit = { has_building = the_great_wall_liaodong } remove_building = the_great_wall_liaodong }
                if = { limit = { has_building = the_great_wall_shanhai_pass } remove_building = the_great_wall_shanhai_pass }
                if = { limit = { has_building = the_pyramids_01 } remove_building = the_pyramids_01 }
                if = { limit = { has_building = the_tower_of_london_01 } remove_building = the_tower_of_london_01 }
                if = { limit = { has_building = theodosian_walls_01 } remove_building = theodosian_walls_01 }
                if = { limit = { has_building = three_pagodas_dali_01 } remove_building = three_pagodas_dali_01 }
                if = { limit = { has_building = thuriang_kilns_01 } remove_building = thuriang_kilns_01 }
                if = { limit = { has_building = tiantai_monasteries_01 } remove_building = tiantai_monasteries_01 }
                if = { limit = { has_building = tomb_of_cyrus_01 } remove_building = tomb_of_cyrus_01 }
                if = { limit = { has_building = tower_of_hercules_01 } remove_building = tower_of_hercules_01 }
                if = { limit = { has_building = tower_of_silence_01 } remove_building = tower_of_silence_01 }
                if = { limit = { has_building = trepca_mines_04 } remove_building = trepca_mines_04 }
                else_if = { limit = { has_building = trepca_mines_03 } remove_building = trepca_mines_03 }
                else_if = { limit = { has_building = trepca_mines_02 } remove_building = trepca_mines_02 }
                else_if = { limit = { has_building = trepca_mines_01 } remove_building = trepca_mines_01 }
                if = { limit = { has_building = trosky_castle_01 } remove_building = trosky_castle_01 }
                if = { limit = { has_building = tsushima_mines_04 } remove_building = tsushima_mines_04 }
                else_if = { limit = { has_building = tsushima_mines_03 } remove_building = tsushima_mines_03 }
                else_if = { limit = { has_building = tsushima_mines_02 } remove_building = tsushima_mines_02 }
                else_if = { limit = { has_building = tsushima_mines_01 } remove_building = tsushima_mines_01 }
                if = { limit = { has_building = turda_mines_04 } remove_building = turda_mines_04 }
                else_if = { limit = { has_building = turda_mines_03 } remove_building = turda_mines_03 }
                else_if = { limit = { has_building = turda_mines_02 } remove_building = turda_mines_02 }
                else_if = { limit = { has_building = turda_mines_01 } remove_building = turda_mines_01 }
                if = { limit = { has_building = vatapi_caves_01 } remove_building = vatapi_caves_01 }
                if = { limit = { has_building = verespatak_mines_04 } remove_building = verespatak_mines_04 }
                else_if = { limit = { has_building = verespatak_mines_03 } remove_building = verespatak_mines_03 }
                else_if = { limit = { has_building = verespatak_mines_02 } remove_building = verespatak_mines_02 }
                else_if = { limit = { has_building = verespatak_mines_01 } remove_building = verespatak_mines_01 }
                DI_remove_building_type_effect = { BUILDING = vihara_halls }
                if = { limit = { has_building = visby_ringmur_01 } remove_building = visby_ringmur_01 }
                if = { limit = { has_building = visegrad_castle_01 } remove_building = visegrad_castle_01 }
                if = { limit = { has_building = walls_04 } remove_building = walls_04 }
                else_if = { limit = { has_building = walls_03 } remove_building = walls_03 }
                else_if = { limit = { has_building = walls_02 } remove_building = walls_02 }
                else_if = { limit = { has_building = walls_01 } remove_building = walls_01 }
                else_if = { limit = { has_building = walls_00 } remove_building = walls_00 }
                if = { limit = { has_building = walls_01_tribal } remove_building = walls_01_tribal }
                if = { limit = { has_building = walls_of_benin_01 } remove_building = walls_of_benin_01 }
                if = { limit = { has_building = walls_of_genoa_01 } remove_building = walls_of_genoa_01 }
                if = { limit = { has_building = wantilan_04 } remove_building = wantilan_04 }
                else_if = { limit = { has_building = wantilan_03 } remove_building = wantilan_03 }
                else_if = { limit = { has_building = wantilan_02 } remove_building = wantilan_02 }
                else_if = { limit = { has_building = wantilan_01 } remove_building = wantilan_01 }
                if = { limit = { has_building = war_camps_02 } remove_building = war_camps_02 }
                else_if = { limit = { has_building = war_camps_01 } remove_building = war_camps_01 }
                DI_remove_building_type_effect = { BUILDING = warrior_lodges }
                if = { limit = { has_building = wartburg_01 } remove_building = wartburg_01 }
                DI_remove_building_type_effect = { BUILDING = watchtowers }
                if = { limit = { has_building = water_temples_04 } remove_building = water_temples_04 }
                else_if = { limit = { has_building = water_temples_03 } remove_building = water_temples_03 }
                else_if = { limit = { has_building = water_temples_02 } remove_building = water_temples_02 }
                else_if = { limit = { has_building = water_temples_01 } remove_building = water_temples_01 }
                DI_remove_building_type_effect = { BUILDING = watermills }
                DI_remove_building_type_effect = { BUILDING = waterworks }
                if = { limit = { has_building = wawel_cathedral_03 } remove_building = wawel_cathedral_03 }
                else_if = { limit = { has_building = wawel_cathedral_02 } remove_building = wawel_cathedral_02 }
                else_if = { limit = { has_building = wawel_cathedral_01 } remove_building = wawel_cathedral_01 }
                if = { limit = { has_building = white_deer_grotto_academy_01 } remove_building = white_deer_grotto_academy_01 }
                if = { limit = { has_building = wilwatikta_palace_01 } remove_building = wilwatikta_palace_01 }
                DI_remove_building_type_effect = { BUILDING = wind_furnace }
                DI_remove_building_type_effect = { BUILDING = windmills }
                DI_remove_building_type_effect = { BUILDING = workshops }
                if = { limit = { has_building = wudang_mountain_temples_01 } remove_building = wudang_mountain_temples_01 }
                if = { limit = { has_building = wulingyuan_01 } remove_building = wulingyuan_01 }
                if = { limit = { has_building = xiuyan_mines_04 } remove_building = xiuyan_mines_04 }
                else_if = { limit = { has_building = xiuyan_mines_03 } remove_building = xiuyan_mines_03 }
                else_if = { limit = { has_building = xiuyan_mines_02 } remove_building = xiuyan_mines_02 }
                else_if = { limit = { has_building = xiuyan_mines_01 } remove_building = xiuyan_mines_01 }
                if = { limit = { has_building = yazd_mosque_01 } remove_building = yazd_mosque_01 }
                if = { limit = { has_building = york_walls_01 } remove_building = york_walls_01 }
                if = { limit = { has_building = yuelu_academy_01 } remove_building = yuelu_academy_01 }
                if = { limit = { has_building = yungang_grottoes_01 } remove_building = yungang_grottoes_01 }
                if = { limit = { has_building = zawar_mines_04 } remove_building = zawar_mines_04 }
                else_if = { limit = { has_building = zawar_mines_03 } remove_building = zawar_mines_03 }
                else_if = { limit = { has_building = zawar_mines_02 } remove_building = zawar_mines_02 }
                else_if = { limit = { has_building = zawar_mines_01 } remove_building = zawar_mines_01 }
                if = { limit = { has_building = zigong_mines_04 } remove_building = zigong_mines_04 }
                else_if = { limit = { has_building = zigong_mines_03 } remove_building = zigong_mines_03 }
                else_if = { limit = { has_building = zigong_mines_02 } remove_building = zigong_mines_02 }
                else_if = { limit = { has_building = zigong_mines_01 } remove_building = zigong_mines_01 }
                if = { limit = { has_building = zijinshan_mines_04 } remove_building = zijinshan_mines_04 }
                else_if = { limit = { has_building = zijinshan_mines_03 } remove_building = zijinshan_mines_03 }
                else_if = { limit = { has_building = zijinshan_mines_02 } remove_building = zijinshan_mines_02 }
                else_if = { limit = { has_building = zijinshan_mines_01 } remove_building = zijinshan_mines_01 }
            }
        }
    }
}

DI_max_building_upgrades_sgui = {
    scope = character # Player Character

    effect = {
        save_scope_as = player

        every_in_list = {
            variable = DI_action_provinces
            save_scope_as = province

            scope:province = {
                if = {
                    limit = {
                        has_building_or_higher = al_azhar_university
                        NOT = { has_building = al_azhar_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = al_azhar_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = al_azhar_university
                }
                if = {
                    limit = {
                        has_building_or_higher = al_qarawiyyin_university_01
                        NOT = { has_building = al_qarawiyyin_university_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = al_qarawiyyin_university_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = al_qarawiyyin_university_01
                }
                if = {
                    limit = {
                        has_building_or_higher = alamut_castle_01
                        NOT = { has_building = alamut_castle_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alamut_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alamut_castle_02
                }
                if = {
                    limit = {
                        has_building_or_higher = alcazar_of_segovia_01
                        NOT = { has_building = alcazar_of_segovia_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alcazar_of_segovia_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alcazar_of_segovia_01
                }
                if = {
                    limit = {
                        has_building_or_higher = alhambra_01
                        NOT = { has_building = alhambra_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = alhambra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = alhambra_02
                }
                if = {
                    limit = {
                        has_building_or_higher = aljaferia_palace_01
                        NOT = { has_building = aljaferia_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = aljaferia_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = aljaferia_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = allaq_mines_01
                        NOT = { has_building = allaq_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = allaq_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = allaq_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = ananda_temple_01
                        NOT = { has_building = ananda_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ananda_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ananda_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = angkor_wat_01
                        NOT = { has_building = angkor_wat_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = angkor_wat_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = angkor_wat_01
                }
                if = {
                    limit = {
                        has_building_or_higher = apollinare_nuovo
                        NOT = { has_building = apollinare_nuovo }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = apollinare_nuovo
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = apollinare_nuovo
                }
                if = {
                    limit = {
                        has_building_or_higher = archery_ranges_01
                        NOT = { has_building = archery_ranges_03 }
                    }
                    add_building = archery_ranges_03
                }
                if = {
                    limit = {
                        has_building_or_higher = argentiera_mines_01
                        NOT = { has_building = argentiera_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = argentiera_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = argentiera_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = ark_of_bukhara_01
                        NOT = { has_building = ark_of_bukhara_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ark_of_bukhara_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ark_of_bukhara_01
                }
                if = {
                    limit = {
                        has_building_or_higher = assassin_castle_01
                        NOT = { has_building = assassin_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = assassin_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = assassin_castle_01
                }
                if = {
                    limit = {
                        has_building_or_higher = aurelian_walls_01
                        NOT = { has_building = aurelian_walls_01 }
                    }
                    add_building = aurelian_walls_01
                }
                if = {
                    limit = {
                        has_building_or_higher = baofeng_mines_01
                        NOT = { has_building = baofeng_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = baofeng_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = baofeng_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = barracks_01
                        NOT = { has_building = barracks_08 }
                    }
                    add_building = barracks_08
                }
                if = {
                    limit = {
                        has_building_or_higher = besakih_temple_01
                        NOT = { has_building = besakih_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = besakih_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = besakih_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = beta_giyorgis_01
                        NOT = { has_building = beta_giyorgis_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = beta_giyorgis_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = beta_giyorgis_01
                }
                if = {
                    limit = {
                        has_building_or_higher = blacksmiths_01
                        NOT = { has_building = blacksmiths_03 }
                    }
                    add_building = blacksmiths_03
                }
                if = {
                    limit = {
                        has_building_or_higher = borobudur_01
                        NOT = { has_building = borobudur_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = borobudur_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = borobudur_01
                }
                if = {
                    limit = {
                        has_building_or_higher = boudhanath_01
                        NOT = { has_building = boudhanath_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = boudhanath_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = boudhanath_01
                }
                if = {
                    limit = {
                        has_building_or_higher = breweries_01
                        NOT = { has_building = breweries_08 }
                    }
                    add_building = breweries_08
                }
                if = {
                    limit = {
                        has_building_or_higher = brihadeeswarar_temple_01
                        NOT = { has_building = brihadeeswarar_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = brihadeeswarar_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = brihadeeswarar_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = buddha_kamakura_01
                        NOT = { has_building = buddha_kamakura_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = buddha_kamakura_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = buddha_kamakura_01
                }
                if = {
                    limit = {
                        has_building_or_higher = buddhas_of_bamian_01
                        NOT = { has_building = buddhas_of_bamian_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = buddhas_of_bamian_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = buddhas_of_bamian_01
                }
                if = {
                    limit = {
                        has_building_or_higher = burial_site_01
                        NOT = { has_building = burial_site_03 }
                    }
                    add_building = burial_site_03
                }
                if = {
                    limit = {
                        has_building_or_higher = burkhan_khaldun_01
                        NOT = { has_building = burkhan_khaldun_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = burkhan_khaldun_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = burkhan_khaldun_01
                }
                if = {
                    limit = {
                        has_building_or_higher = byeokran_port_01
                        NOT = { has_building = byeokran_port_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = byeokran_port_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = byeokran_port_01
                }
                if = {
                    limit = {
                        has_building_or_higher = camel_farms_01
                        NOT = { has_building = camel_farms_08 }
                    }
                    add_building = camel_farms_08
                }
                if = {
                    limit = {
                        has_building_or_higher = capital_bureau_01
                        NOT = { has_building = capital_bureau_08 }
                    }
                    add_building = capital_bureau_08
                }
                if = {
                    limit = {
                        has_building_or_higher = caravanserai_01
                        NOT = { has_building = caravanserai_08 }
                    }
                    add_building = caravanserai_08
                }
                if = {
                    limit = {
                        has_building_or_higher = castle_01
                        NOT = { has_building = castle_04 }
                    }
                    add_building = castle_04
                }
                if = {
                    limit = {
                        has_building_or_higher = cattolica_stilo
                        NOT = { has_building = cattolica_stilo }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cattolica_stilo
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cattolica_stilo
                }
                if = {
                    limit = {
                        has_building_or_higher = celestial_great_barracks_01
                        NOT = { has_building = celestial_great_barracks_01 }
                    }
                    add_building = celestial_great_barracks_01
                }
                if = {
                    limit = {
                        has_building_or_higher = cereal_fields_01
                        NOT = { has_building = cereal_fields_08 }
                    }
                    add_building = cereal_fields_08
                }
                if = {
                    limit = {
                        has_building_or_higher = cevennes_mines_01
                        NOT = { has_building = cevennes_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cevennes_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cevennes_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = changan_market_01
                        NOT = { has_building = changan_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = changan_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = changan_market_02
                }
                if = {
                    limit = {
                        has_building_or_higher = charnel_grounds_01
                        NOT = { has_building = charnel_grounds_03 }
                    }
                    add_building = charnel_grounds_03
                }
                if = {
                    limit = {
                        has_building_or_higher = chihu_mines_01
                        NOT = { has_building = chihu_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chihu_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chihu_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = chinjufu_01
                        NOT = { has_building = chinjufu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chinjufu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chinjufu_01
                }
                if = {
                    limit = {
                        has_building_or_higher = chocolate_hills_01
                        NOT = { has_building = chocolate_hills_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = chocolate_hills_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = chocolate_hills_01
                }
                if = {
                    limit = {
                        has_building_or_higher = church_of_the_theotokos
                        NOT = { has_building = parthenon }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = church_of_the_theotokos
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = parthenon
                }
                if = {
                    limit = {
                        has_building_or_higher = cilician_gates
                        NOT = { has_building = cilician_gates }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cilician_gates
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cilician_gates
                }
                if = {
                    limit = {
                        has_building_or_higher = citadel_linan_01
                        NOT = { has_building = citadel_linan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_linan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_linan_01
                }
                if = {
                    limit = {
                        has_building_or_higher = citadel_of_aleppo_01
                        NOT = { has_building = citadel_of_aleppo_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_of_aleppo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_of_aleppo_02
                }
                if = {
                    limit = {
                        has_building_or_higher = citadel_shrine_01
                        NOT = { has_building = citadel_shrine_08 }
                    }
                    add_building = citadel_shrine_08
                }
                if = {
                    limit = {
                        has_building_or_higher = citadel_thang_long_01
                        NOT = { has_building = citadel_thang_long_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = citadel_thang_long_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = citadel_thang_long_02
                }
                if = {
                    limit = {
                        has_building_or_higher = city_01
                        NOT = { has_building = city_04 }
                    }
                    add_building = city_04
                }
                if = {
                    limit = {
                        has_building_or_higher = city_wall_of_toledo_01
                        NOT = { has_building = city_wall_of_toledo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = city_wall_of_toledo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = city_wall_of_toledo_01
                }
                if = {
                    limit = {
                        has_building_or_higher = cluny_abbey_01
                        NOT = { has_building = cluny_abbey_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = cluny_abbey_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = cluny_abbey_02
                }
                if = {
                    limit = {
                        has_building_or_higher = common_tradeport_01
                        NOT = { has_building = common_tradeport_08 }
                    }
                    add_building = common_tradeport_08
                }
                if = {
                    limit = {
                        has_building_or_higher = confucius_temple_01
                        NOT = { has_building = confucius_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = confucius_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = confucius_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = culai_academy_01
                        NOT = { has_building = culai_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = culai_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = culai_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = curtain_walls_01
                        NOT = { has_building = curtain_walls_08 }
                    }
                    add_building = curtain_walls_08
                }
                if = {
                    limit = {
                        has_building_or_higher = damascus_mosque_01
                        NOT = { has_building = damascus_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = damascus_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = damascus_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = danevirke_01
                        NOT = { has_building = danevirke_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = danevirke_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = danevirke_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dau_temple_01
                        NOT = { has_building = dau_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dau_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dau_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dazaifu_01
                        NOT = { has_building = dazaifu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dazaifu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dazaifu_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dean_mines_01
                        NOT = { has_building = dean_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dean_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dean_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = dengfeng_observatory_01
                        NOT = { has_building = dengfeng_observatory_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dengfeng_observatory_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dengfeng_observatory_01
                }
                if = {
                    limit = {
                        has_building_or_higher = despot_palace
                        NOT = { has_building = despot_palace }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = despot_palace
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = despot_palace
                }
                if = {
                    limit = {
                        has_building_or_higher = dieng_plateau_01
                        NOT = { has_building = dieng_plateau_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dieng_plateau_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dieng_plateau_01
                }
                if = {
                    limit = {
                        has_building_or_higher = doges_palace_01
                        NOT = { has_building = doges_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = doges_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = doges_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dome_of_the_rock_01
                        NOT = { has_building = temple_in_jerusalem_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dome_of_the_rock_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temple_in_jerusalem_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dragon_kiln_01
                        NOT = { has_building = dragon_kiln_03 }
                    }
                    add_building = dragon_kiln_03
                }
                if = {
                    limit = {
                        has_building_or_higher = drassanes_01
                        NOT = { has_building = drassanes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = drassanes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = drassanes_01
                }
                if = {
                    limit = {
                        has_building_or_higher = dunhuang_market_01
                        NOT = { has_building = dunhuang_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dunhuang_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dunhuang_market_02
                }
                if = {
                    limit = {
                        has_building_or_higher = duomo_florence_01
                        NOT = { has_building = duomo_florence_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = duomo_florence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = duomo_florence_04
                }
                if = {
                    limit = {
                        has_building_or_higher = dushan_mines_01
                        NOT = { has_building = dushan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dushan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dushan_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = dvin_shuka_01
                        NOT = { has_building = dvin_shuka_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = dvin_shuka_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = dvin_shuka_02
                }
                if = {
                    limit = {
                        has_building_or_higher = elephant_pens_01
                        NOT = { has_building = elephant_pens_08 }
                    }
                    add_building = elephant_pens_08
                }
                if = {
                    limit = {
                        has_building_or_higher = enryaku_ji_01
                        NOT = { has_building = enryaku_ji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = enryaku_ji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = enryaku_ji_01
                }
                if = {
                    limit = {
                        has_building_or_higher = etchmiadzin_cathedral
                        NOT = { has_building = etchmiadzin_cathedral }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = etchmiadzin_cathedral
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = etchmiadzin_cathedral
                }
                if = {
                    limit = {
                        has_building_or_higher = event_tower_of_silence_01
                        NOT = { has_building = event_tower_of_silence_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = event_tower_of_silence_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = event_tower_of_silence_01
                }
                if = {
                    limit = {
                        has_building_or_higher = examination_hall_01
                        NOT = { has_building = examination_hall_03 }
                    }
                    add_building = examination_hall_03
                }
                if = {
                    limit = {
                        has_building_or_higher = fairy_chimneys
                        NOT = { has_building = fairy_chimneys }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fairy_chimneys
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fairy_chimneys
                }
                if = {
                    limit = {
                        has_building_or_higher = falak_ol_aflak_citadel_01
                        NOT = { has_building = falak_ol_aflak_citadel_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falak_ol_aflak_citadel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falak_ol_aflak_citadel_01
                }
                if = {
                    limit = {
                        has_building_or_higher = falun_mines_01
                        NOT = { has_building = falun_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = falun_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = falun_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = fanfang_guangzhou_01
                        NOT = { has_building = fanfang_guangzhou_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fanfang_guangzhou_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fanfang_guangzhou_01
                }
                if = {
                    limit = {
                        has_building_or_higher = farm_estates_01
                        NOT = { has_building = farm_estates_08 }
                    }
                    add_building = farm_estates_08
                }
                if = {
                    limit = {
                        has_building_or_higher = fengtian_mines_01
                        NOT = { has_building = fengtian_mines_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = fengtian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = fengtian_mines_03
                }
                if = {
                    limit = {
                        has_building_or_higher = forbidden_city_01
                        NOT = { has_building = forbidden_city_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = forbidden_city_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = forbidden_city_01
                }
                if = {
                    limit = {
                        has_building_or_higher = generic_copper_mines_01
                        NOT = { has_building = generic_copper_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_copper_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_copper_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = generic_gold_mines_01
                        NOT = { has_building = generic_gold_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_gold_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_gold_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = generic_silver_mines_01
                        NOT = { has_building = generic_silver_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_silver_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_silver_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = generic_university
                        NOT = { has_building = generic_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = generic_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = generic_university
                }
                if = {
                    limit = {
                        has_building_or_higher = ghana_palace_01
                        NOT = { has_building = ghana_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ghana_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ghana_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = giant_wild_goose_pagoda_01
                        NOT = { has_building = giant_wild_goose_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = giant_wild_goose_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = giant_wild_goose_pagoda_01
                }
                if = {
                    limit = {
                        has_building_or_higher = goguryeo_tomb_01
                        NOT = { has_building = goguryeo_tomb_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = goguryeo_tomb_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = goguryeo_tomb_01
                }
                if = {
                    limit = {
                        has_building_or_higher = golden_gate_of_kiev_01
                        NOT = { has_building = golden_gate_of_kiev_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = golden_gate_of_kiev_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = golden_gate_of_kiev_01
                }
                if = {
                    limit = {
                        has_building_or_higher = gongsanseong_fortress_01
                        NOT = { has_building = gongsanseong_fortress_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = gongsanseong_fortress_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = gongsanseong_fortress_01
                }
                if = {
                    limit = {
                        has_building_or_higher = great_megalith_01
                        NOT = { has_building = great_megalith_01 }
                    }
                    add_building = great_megalith_01
                }
                if = {
                    limit = {
                        has_building_or_higher = great_project_cathedral_01
                        NOT = { has_building = great_project_cathedral_03 }
                    }
                    add_building = great_project_cathedral_03
                }
                if = {
                    limit = {
                        has_building_or_higher = great_project_cathedral_under_construction
                        NOT = { has_building = great_project_cathedral_under_construction }
                    }
                    add_building = great_project_cathedral_under_construction
                }
                if = {
                    limit = {
                        has_building_or_higher = great_wall_of_gorgan_01
                        NOT = { has_building = great_wall_of_gorgan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = great_wall_of_gorgan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = great_wall_of_gorgan_01
                }
                if = {
                    limit = {
                        has_building_or_higher = guild_halls_01
                        NOT = { has_building = guild_halls_08 }
                    }
                    add_building = guild_halls_08
                }
                if = {
                    limit = {
                        has_building_or_higher = guiyang_mines_01
                        NOT = { has_building = guiyang_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = guiyang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = guiyang_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = gunung_api_01
                        NOT = { has_building = gunung_api_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = gunung_api_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = gunung_api_01
                }
                if = {
                    limit = {
                        has_building_or_higher = ha_long_bay_01
                        NOT = { has_building = ha_long_bay_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ha_long_bay_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ha_long_bay_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hadrians_wall_01
                        NOT = { has_building = hadrians_wall_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hadrians_wall_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hadrians_wall_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hagia_sophia_01
                        NOT = { has_building = hagia_sophia_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hagia_sophia_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hagia_sophia_02
                }
                if = {
                    limit = {
                        has_building_or_higher = hagios_demetrios
                        NOT = { has_building = hagios_demetrios }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hagios_demetrios
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hagios_demetrios
                }
                if = {
                    limit = {
                        has_building_or_higher = hakata_port_01
                        NOT = { has_building = hakata_port_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hakata_port_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hakata_port_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hall_of_heroes_01
                        NOT = { has_building = hall_of_heroes_05 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hall_of_heroes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hall_of_heroes_05
                }
                if = {
                    limit = {
                        has_building_or_higher = hamadan_bazaar_01
                        NOT = { has_building = hamadan_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hamadan_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hamadan_bazaar_02
                }
                if = {
                    limit = {
                        has_building_or_higher = hanging_temple_01
                        NOT = { has_building = hanging_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanging_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanging_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hanxing_mines_01
                        NOT = { has_building = hanxing_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hanxing_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hanxing_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = heddal_stave_church_01
                        NOT = { has_building = heddal_stave_church_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = heddal_stave_church_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = heddal_stave_church_01
                }
                if = {
                    limit = {
                        has_building_or_higher = heian_palace_01
                        NOT = { has_building = heian_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = heian_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = heian_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = herat_bazaar_01
                        NOT = { has_building = herat_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = herat_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = herat_bazaar_02
                }
                if = {
                    limit = {
                        has_building_or_higher = herder_camp_01
                        NOT = { has_building = herder_camp_01 }
                    }
                    add_building = herder_camp_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hetian_mines_01
                        NOT = { has_building = hetian_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hetian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hetian_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = hill_farms_01
                        NOT = { has_building = hill_farms_08 }
                    }
                    add_building = hill_farms_08
                }
                if = {
                    limit = {
                        has_building_or_higher = hill_forts_01
                        NOT = { has_building = hill_forts_08 }
                    }
                    add_building = hill_forts_08
                }
                if = {
                    limit = {
                        has_building_or_higher = hillside_grazing_01
                        NOT = { has_building = hillside_grazing_08 }
                    }
                    add_building = hillside_grazing_08
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_basilica_santiago_01
                        NOT = { has_building = holy_site_basilica_santiago_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_basilica_santiago_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_basilica_santiago_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_buddhist_grand_temple_01
                        NOT = { has_building = holy_site_buddhist_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_buddhist_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_buddhist_grand_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_canterbury_cathedral_01
                        NOT = { has_building = holy_site_canterbury_cathedral_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_canterbury_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_canterbury_cathedral_03
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_cathedral_01
                        NOT = { has_building = holy_site_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_cathedral_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_chinese_temple_01
                        NOT = { has_building = holy_site_chinese_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_chinese_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_chinese_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_cologne_cathedral_01
                        NOT = { has_building = holy_site_cologne_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_cologne_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_cologne_cathedral_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_fire_temple_01
                        NOT = { has_building = holy_site_fire_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_fire_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_fire_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_great_mosque_of_cordoba_01
                        NOT = { has_building = holy_site_great_mosque_of_cordoba_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_cordoba_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_cordoba_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_great_mosque_of_djenne_01
                        NOT = { has_building = holy_site_great_mosque_of_djenne_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_djenne_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_djenne_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_great_mosque_of_mecca_01
                        NOT = { has_building = holy_site_great_mosque_of_mecca_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_mecca_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_mecca_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_great_mosque_of_samarra_01
                        NOT = { has_building = holy_site_great_mosque_of_samarra_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_great_mosque_of_samarra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_great_mosque_of_samarra_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_imam_ali_mosque_01
                        NOT = { has_building = holy_site_imam_ali_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_imam_ali_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_imam_ali_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_indian_grand_temple_01
                        NOT = { has_building = holy_site_indian_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_indian_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_indian_grand_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_japanese_temple_01
                        NOT = { has_building = holy_site_japanese_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_japanese_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_japanese_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_mahabodhi_temple_01
                        NOT = { has_building = holy_site_mahabodhi_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_mahabodhi_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_mahabodhi_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_mosque_01
                        NOT = { has_building = holy_site_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_other_grand_temple_01
                        NOT = { has_building = holy_site_other_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_other_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_other_grand_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_pagan_grand_temple_01
                        NOT = { has_building = holy_site_pagan_grand_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_pagan_grand_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_pagan_grand_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_prophetic_mosque_01
                        NOT = { has_building = holy_site_prophetic_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_prophetic_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_prophetic_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_se_asia_pagan_temple_01
                        NOT = { has_building = holy_site_se_asia_pagan_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_se_asia_pagan_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_se_asia_pagan_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_site_st_peters_basilica_01
                        NOT = { has_building = holy_site_st_peters_basilica_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_site_st_peters_basilica_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_site_st_peters_basilica_01
                }
                if = {
                    limit = {
                        has_building_or_higher = holy_wisdom_01
                        NOT = { has_building = holy_wisdom_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = holy_wisdom_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = holy_wisdom_01
                }
                if = {
                    limit = {
                        has_building_or_higher = horse_pastures_01
                        NOT = { has_building = horse_pastures_08 }
                    }
                    add_building = horse_pastures_08
                }
                if = {
                    limit = {
                        has_building_or_higher = hoshi_ryokan_01
                        NOT = { has_building = hoshi_ryokan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hoshi_ryokan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hoshi_ryokan_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hosios_loukas
                        NOT = { has_building = hosios_loukas }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hosios_loukas
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hosios_loukas
                }
                if = {
                    limit = {
                        has_building_or_higher = hospices_01
                        NOT = { has_building = hospices_08 }
                    }
                    add_building = hospices_08
                }
                if = {
                    limit = {
                        has_building_or_higher = hotin_fort_01
                        NOT = { has_building = hotin_fort_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hotin_fort_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hotin_fort_02
                }
                if = {
                    limit = {
                        has_building_or_higher = house_of_wisdom_01
                        NOT = { has_building = house_of_wisdom_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = house_of_wisdom_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = house_of_wisdom_01
                }
                if = {
                    limit = {
                        has_building_or_higher = hpakant_mines_01
                        NOT = { has_building = hpakant_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hpakant_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hpakant_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = hunting_grounds_01
                        NOT = { has_building = hunting_grounds_08 }
                    }
                    add_building = hunting_grounds_08
                }
                if = {
                    limit = {
                        has_building_or_higher = hwangnyongsa_01
                        NOT = { has_building = hwangnyongsa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = hwangnyongsa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = hwangnyongsa_01
                }
                if = {
                    limit = {
                        has_building_or_higher = idjang_forts_01
                        NOT = { has_building = idjang_forts_04 }
                    }
                    add_building = idjang_forts_04
                }
                if = {
                    limit = {
                        has_building_or_higher = ijil_mines_01
                        NOT = { has_building = ijil_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ijil_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ijil_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = imam_reza_shrine_01
                        NOT = { has_building = imam_reza_shrine_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = imam_reza_shrine_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = imam_reza_shrine_01
                }
                if = {
                    limit = {
                        has_building_or_higher = iron_lion_cangzhou_01
                        NOT = { has_building = iron_lion_cangzhou_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_lion_cangzhou_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_lion_cangzhou_01
                }
                if = {
                    limit = {
                        has_building_or_higher = iron_pillar_of_delhi_01
                        NOT = { has_building = iron_pillar_of_delhi_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_pillar_of_delhi_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_pillar_of_delhi_01
                }
                if = {
                    limit = {
                        has_building_or_higher = iron_pillar_of_dhar_01
                        NOT = { has_building = iron_pillar_of_dhar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = iron_pillar_of_dhar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = iron_pillar_of_dhar_01
                }
                if = {
                    limit = {
                        has_building_or_higher = ise_jingu_01
                        NOT = { has_building = ise_jingu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ise_jingu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ise_jingu_01
                }
                if = {
                    limit = {
                        has_building_or_higher = itoigawa_mines_01
                        NOT = { has_building = itoigawa_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itoigawa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itoigawa_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = itsukushima_jinja_01
                        NOT = { has_building = itsukushima_jinja_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = itsukushima_jinja_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = itsukushima_jinja_02
                }
                if = {
                    limit = {
                        has_building_or_higher = izumo_taisha_01
                        NOT = { has_building = izumo_taisha_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = izumo_taisha_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = izumo_taisha_01
                }
                if = {
                    limit = {
                        has_building_or_higher = jaisalmer_fort_01
                        NOT = { has_building = jaisalmer_fort_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jaisalmer_fort_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jaisalmer_fort_01
                }
                if = {
                    limit = {
                        has_building_or_higher = jiaodong_mines_01
                        NOT = { has_building = jiaodong_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jiaodong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jiaodong_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = jizu_shan_temples_01
                        NOT = { has_building = jizu_shan_temples_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jizu_shan_temples_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jizu_shan_temples_01
                }
                if = {
                    limit = {
                        has_building_or_higher = jokhang_01
                        NOT = { has_building = jokhang_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jokhang_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jokhang_01
                }
                if = {
                    limit = {
                        has_building_or_higher = jousting_lists_01
                        NOT = { has_building = jousting_lists_03 }
                    }
                    add_building = jousting_lists_03
                }
                if = {
                    limit = {
                        has_building_or_higher = jvari_monastery
                        NOT = { has_building = jvari_monastery }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = jvari_monastery
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = jvari_monastery
                }
                if = {
                    limit = {
                        has_building_or_higher = kaibao_mines_01
                        NOT = { has_building = kaibao_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaibao_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaibao_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = kaifeng_palace_01
                        NOT = { has_building = kaifeng_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kaifeng_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kaifeng_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = kairouan_basins_01
                        NOT = { has_building = kairouan_basins_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kairouan_basins_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kairouan_basins_01
                }
                if = {
                    limit = {
                        has_building_or_higher = kano_walls_01
                        NOT = { has_building = kano_walls_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kano_walls_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kano_walls_01
                }
                if = {
                    limit = {
                        has_building_or_higher = kassiopi_castle
                        NOT = { has_building = kassiopi_castle }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kassiopi_castle
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kassiopi_castle
                }
                if = {
                    limit = {
                        has_building_or_higher = khajuraho_01
                        NOT = { has_building = khajuraho_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khajuraho_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khajuraho_01
                }
                if = {
                    limit = {
                        has_building_or_higher = khetri_mines_01
                        NOT = { has_building = khetri_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khetri_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khetri_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = khiva_bazaar_01
                        NOT = { has_building = khiva_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = khiva_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = khiva_bazaar_02
                }
                if = {
                    limit = {
                        has_building_or_higher = kofuku_ji_01
                        NOT = { has_building = kofuku_ji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kofuku_ji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kofuku_ji_01
                }
                if = {
                    limit = {
                        has_building_or_higher = koganeyama_mines_01
                        NOT = { has_building = koganeyama_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = koganeyama_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = koganeyama_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = kollur_mines_01
                        NOT = { has_building = kollur_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kollur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kollur_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = konark_temple_01
                        NOT = { has_building = konark_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konark_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konark_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = konasamudram_mines_01
                        NOT = { has_building = konasamudram_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = konasamudram_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = konasamudram_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = kora_kora_yards_01
                        NOT = { has_building = kora_kora_yards_04 }
                    }
                    add_building = kora_kora_yards_04
                }
                if = {
                    limit = {
                        has_building_or_higher = krakatoa_01
                        NOT = { has_building = krakatoa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = krakatoa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = krakatoa_01
                }
                if = {
                    limit = {
                        has_building_or_higher = kremnica_mines_01
                        NOT = { has_building = kremnica_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kremnica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kremnica_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = kutna_hora_mines_01
                        NOT = { has_building = kutna_hora_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kutna_hora_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kutna_hora_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = kyz_kala_01
                        NOT = { has_building = kyz_kala_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = kyz_kala_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = kyz_kala_01
                }
                if = {
                    limit = {
                        has_building_or_higher = lahur_bazaar_01
                        NOT = { has_building = lahur_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lahur_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lahur_bazaar_02
                }
                if = {
                    limit = {
                        has_building_or_higher = lantian_mines_01
                        NOT = { has_building = lantian_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lantian_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lantian_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = legendary_hunting_lodge
                        NOT = { has_building = legendary_hunting_lodge }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_hunting_lodge
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_hunting_lodge
                }
                if = {
                    limit = {
                        has_building_or_higher = legendary_palace
                        NOT = { has_building = legendary_palace }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_palace
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_palace
                }
                if = {
                    limit = {
                        has_building_or_higher = legendary_shrine
                        NOT = { has_building = legendary_shrine }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_shrine
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_shrine
                }
                if = {
                    limit = {
                        has_building_or_higher = legendary_statue
                        NOT = { has_building = legendary_statue }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_statue
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_statue
                }
                if = {
                    limit = {
                        has_building_or_higher = legendary_watchtower
                        NOT = { has_building = legendary_watchtower }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = legendary_watchtower
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = legendary_watchtower
                }
                if = {
                    limit = {
                        has_building_or_higher = leisure_palace_01
                        NOT = { has_building = leisure_palace_03 }
                    }
                    add_building = leisure_palace_03
                }
                if = {
                    limit = {
                        has_building_or_higher = leshan_giant_buddha_01
                        NOT = { has_building = leshan_giant_buddha_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = leshan_giant_buddha_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = leshan_giant_buddha_01
                }
                if = {
                    limit = {
                        has_building_or_higher = lhasa_market_01
                        NOT = { has_building = lhasa_market_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lhasa_market_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lhasa_market_02
                }
                if = {
                    limit = {
                        has_building_or_higher = liangzhe_mines_01
                        NOT = { has_building = liangzhe_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liangzhe_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liangzhe_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = lingyin_temple_01
                        NOT = { has_building = lingyin_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lingyin_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lingyin_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = liuhe_pagoda_01
                        NOT = { has_building = liuhe_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = liuhe_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = liuhe_pagoda_01
                }
                if = {
                    limit = {
                        has_building_or_higher = lize_academy_01
                        NOT = { has_building = lize_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lize_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lize_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = logging_camps_01
                        NOT = { has_building = logging_camps_08 }
                    }
                    add_building = logging_camps_08
                }
                if = {
                    limit = {
                        has_building_or_higher = london_bridge_01
                        NOT = { has_building = london_bridge_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = london_bridge_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = london_bridge_01
                }
                if = {
                    limit = {
                        has_building_or_higher = longhouses_01
                        NOT = { has_building = longhouses_02 }
                    }
                    add_building = longhouses_02
                }
                if = {
                    limit = {
                        has_building_or_higher = lund_cathedral_01
                        NOT = { has_building = lund_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = lund_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = lund_cathedral_01
                }
                if = {
                    limit = {
                        has_building_or_higher = maharloo_lake_01
                        NOT = { has_building = maharloo_lake_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maharloo_lake_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maharloo_lake_01
                }
                if = {
                    limit = {
                        has_building_or_higher = maiden_tower
                        NOT = { has_building = maiden_tower }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maiden_tower
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maiden_tower
                }
                if = {
                    limit = {
                        has_building_or_higher = maijishan_grottoes_01
                        NOT = { has_building = maijishan_grottoes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maijishan_grottoes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maijishan_grottoes_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mali_mines_01
                        NOT = { has_building = mali_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mali_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mali_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = mandala_capital_01
                        NOT = { has_building = mandala_capital_05 }
                    }
                    add_building = mandala_capital_05
                }
                if = {
                    limit = {
                        has_building_or_higher = maoshan_academy_01
                        NOT = { has_building = maoshan_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = maoshan_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = maoshan_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = march_01
                        NOT = { has_building = march_03 }
                    }
                    add_building = march_03
                }
                if = {
                    limit = {
                        has_building_or_higher = market_villages_01
                        NOT = { has_building = market_villages_02 }
                    }
                    add_building = market_villages_02
                }
                if = {
                    limit = {
                        has_building_or_higher = megalith_01
                        NOT = { has_building = megalith_08 }
                    }
                    add_building = megalith_08
                }
                if = {
                    limit = {
                        has_building_or_higher = meteora_01
                        NOT = { has_building = meteora_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = meteora_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = meteora_02
                }
                if = {
                    limit = {
                        has_building_or_higher = military_academy_01
                        NOT = { has_building = military_academy_03 }
                    }
                    add_building = military_academy_03
                }
                if = {
                    limit = {
                        has_building_or_higher = military_camps_01
                        NOT = { has_building = military_camps_08 }
                    }
                    add_building = military_camps_08
                }
                if = {
                    limit = {
                        has_building_or_higher = minarets_and_remains_of_jam_01
                        NOT = { has_building = minarets_and_remains_of_jam_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = minarets_and_remains_of_jam_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = minarets_and_remains_of_jam_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mogok_mines_01
                        NOT = { has_building = mogok_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mogok_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mogok_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = monastic_schools_01
                        NOT = { has_building = monastic_schools_08 }
                    }
                    add_building = monastic_schools_08
                }
                if = {
                    limit = {
                        has_building_or_higher = mont_st_michel_01
                        NOT = { has_building = mont_st_michel_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mont_st_michel_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mont_st_michel_04
                }
                if = {
                    limit = {
                        has_building_or_higher = mount_apo_01
                        NOT = { has_building = mount_apo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_apo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_apo_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mount_athos_01
                        NOT = { has_building = mount_athos_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_athos_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_athos_03
                }
                if = {
                    limit = {
                        has_building_or_higher = mount_baekdu_01
                        NOT = { has_building = mount_baekdu_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_baekdu_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_baekdu_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mount_damavand_01
                        NOT = { has_building = mount_damavand_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_damavand_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_damavand_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mount_fuji_01
                        NOT = { has_building = mount_fuji_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mount_fuji_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mount_fuji_01
                }
                if = {
                    limit = {
                        has_building_or_higher = mozu_tombs
                        NOT = { has_building = mozu_tombs }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = mozu_tombs
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = mozu_tombs
                }
                if = {
                    limit = {
                        has_building_or_higher = muara_takus_01
                        NOT = { has_building = muara_takus_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = muara_takus_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = muara_takus_01
                }
                if = {
                    limit = {
                        has_building_or_higher = muaro_jambi_01
                        NOT = { has_building = muaro_jambi_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = muaro_jambi_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = muaro_jambi_01
                }
                if = {
                    limit = {
                        has_building_or_higher = murex_farm_01
                        NOT = { has_building = murex_farm_08 }
                    }
                    add_building = murex_farm_08
                }
                if = {
                    limit = {
                        has_building_or_higher = my_son_sanctuary_01
                        NOT = { has_building = my_son_sanctuary_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = my_son_sanctuary_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = my_son_sanctuary_01
                }
                if = {
                    limit = {
                        has_building_or_higher = nalanda_university
                        NOT = { has_building = nalanda_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nalanda_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nalanda_university
                }
                if = {
                    limit = {
                        has_building_or_higher = nanhua_temple_01
                        NOT = { has_building = nanhua_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nanhua_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nanhua_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = nishapur_mines_01
                        NOT = { has_building = nishapur_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = nishapur_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = nishapur_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = nomadic_camp_01
                        NOT = { has_building = nomadic_camp_01 }
                    }
                    add_building = nomadic_camp_01
                }
                if = {
                    limit = {
                        has_building_or_higher = notre_dame_01
                        NOT = { has_building = notre_dame_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = notre_dame_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = notre_dame_01
                }
                if = {
                    limit = {
                        has_building_or_higher = oath_faithful_building_01
                        NOT = { has_building = oath_faithful_building_04 }
                    }
                    add_building = oath_faithful_building_04
                }
                if = {
                    limit = {
                        has_building_or_higher = oath_poor_building_01
                        NOT = { has_building = oath_poor_building_04 }
                    }
                    add_building = oath_poor_building_04
                }
                if = {
                    limit = {
                        has_building_or_higher = oath_warriors_building_01
                        NOT = { has_building = oath_warriors_building_04 }
                    }
                    add_building = oath_warriors_building_04
                }
                if = {
                    limit = {
                        has_building_or_higher = offas_dyke_01
                        NOT = { has_building = offas_dyke_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = offas_dyke_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = offas_dyke_01
                }
                if = {
                    limit = {
                        has_building_or_higher = orchards_01
                        NOT = { has_building = orchards_08 }
                    }
                    add_building = orchards_08
                }
                if = {
                    limit = {
                        has_building_or_higher = outposts_01
                        NOT = { has_building = outposts_08 }
                    }
                    add_building = outposts_08
                }
                if = {
                    limit = {
                        has_building_or_higher = paddy_fields_01
                        NOT = { has_building = paddy_fields_08 }
                    }
                    add_building = paddy_fields_08
                }
                if = {
                    limit = {
                        has_building_or_higher = pagoda_of_fogong_temple_01
                        NOT = { has_building = pagoda_of_fogong_temple_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pagoda_of_fogong_temple_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pagoda_of_fogong_temple_01
                }
                if = {
                    limit = {
                        has_building_or_higher = palace_of_aachen_01
                        NOT = { has_building = palace_of_aachen_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = palace_of_aachen_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = palace_of_aachen_01
                }
                if = {
                    limit = {
                        has_building_or_higher = palace_of_ctesiphon_01
                        NOT = { has_building = palace_of_ctesiphon_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = palace_of_ctesiphon_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = palace_of_ctesiphon_02
                }
                if = {
                    limit = {
                        has_building_or_higher = palisades_01
                        NOT = { has_building = palisades_02 }
                    }
                    add_building = palisades_02
                }
                if = {
                    limit = {
                        has_building_or_higher = pam_abbey_of_st_gall_01
                        NOT = { has_building = pam_abbey_of_st_gall_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_abbey_of_st_gall_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_abbey_of_st_gall_01
                }
                if = {
                    limit = {
                        has_building_or_higher = pam_lateran_basilica_01
                        NOT = { has_building = pam_lateran_basilica_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_lateran_basilica_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_lateran_basilica_01
                }
                if = {
                    limit = {
                        has_building_or_higher = pam_palais_de_papes_01
                        NOT = { has_building = pam_palais_de_papes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_palais_de_papes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_palais_de_papes_01
                }
                if = {
                    limit = {
                        has_building_or_higher = pam_reims_cathedral_01
                        NOT = { has_building = pam_reims_cathedral_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pam_reims_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pam_reims_cathedral_01
                }
                if = {
                    limit = {
                        has_building_or_higher = pansjhir_mines_01
                        NOT = { has_building = pansjhir_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pansjhir_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pansjhir_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = pastures_01
                        NOT = { has_building = pastures_08 }
                    }
                    add_building = pastures_08
                }
                if = {
                    limit = {
                        has_building_or_higher = patras_castle
                        NOT = { has_building = patras_castle }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = patras_castle
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = patras_castle
                }
                if = {
                    limit = {
                        has_building_or_higher = peat_quarries_01
                        NOT = { has_building = peat_quarries_08 }
                    }
                    add_building = peat_quarries_08
                }
                if = {
                    limit = {
                        has_building_or_higher = petra_01
                        NOT = { has_building = petra_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = petra_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = petra_01
                }
                if = {
                    limit = {
                        has_building_or_higher = phnom_dek_mines_01
                        NOT = { has_building = phnom_dek_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phnom_dek_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phnom_dek_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = phocaea_mines_01
                        NOT = { has_building = phocaea_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = phocaea_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = phocaea_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = plain_of_jars_01
                        NOT = { has_building = plain_of_jars_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = plain_of_jars_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = plain_of_jars_01
                }
                if = {
                    limit = {
                        has_building_or_higher = plantations_01
                        NOT = { has_building = plantations_08 }
                    }
                    add_building = plantations_08
                }
                if = {
                    limit = {
                        has_building_or_higher = pleasure_dome
                        NOT = { has_building = pleasure_dome }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pleasure_dome
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pleasure_dome
                }
                if = {
                    limit = {
                        has_building_or_higher = po_klong_garai_01
                        NOT = { has_building = po_klong_garai_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = po_klong_garai_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = po_klong_garai_01
                }
                if = {
                    limit = {
                        has_building_or_higher = powder_magazine_01
                        NOT = { has_building = powder_magazine_08 }
                    }
                    add_building = powder_magazine_08
                }
                if = {
                    limit = {
                        has_building_or_higher = pyramid_lingapura_01
                        NOT = { has_building = pyramid_lingapura_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = pyramid_lingapura_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = pyramid_lingapura_01
                }
                if = {
                    limit = {
                        has_building_or_higher = qanats_01
                        NOT = { has_building = qanats_08 }
                    }
                    add_building = qanats_08
                }
                if = {
                    limit = {
                        has_building_or_higher = qianling_mausoleum_01
                        NOT = { has_building = qianling_mausoleum_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qianling_mausoleum_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qianling_mausoleum_01
                }
                if = {
                    limit = {
                        has_building_or_higher = quanzhou_seaport_01
                        NOT = { has_building = quanzhou_seaport_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = quanzhou_seaport_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = quanzhou_seaport_01
                }
                if = {
                    limit = {
                        has_building_or_higher = quarries_01
                        NOT = { has_building = quarries_08 }
                    }
                    add_building = quarries_08
                }
                if = {
                    limit = {
                        has_building_or_higher = qutb_minar_01
                        NOT = { has_building = qutb_minar_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = qutb_minar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = qutb_minar_04
                }
                if = {
                    limit = {
                        has_building_or_higher = rainbow_mountains_01
                        NOT = { has_building = rainbow_mountains_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rainbow_mountains_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rainbow_mountains_01
                }
                if = {
                    limit = {
                        has_building_or_higher = rammelsberg_mines_01
                        NOT = { has_building = rammelsberg_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rammelsberg_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rammelsberg_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = ramparts_01
                        NOT = { has_building = ramparts_08 }
                    }
                    add_building = ramparts_08
                }
                if = {
                    limit = {
                        has_building_or_higher = ratnapura_mines_01
                        NOT = { has_building = ratnapura_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = ratnapura_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = ratnapura_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = regimental_grounds_01
                        NOT = { has_building = regimental_grounds_08 }
                    }
                    add_building = regimental_grounds_08
                }
                if = {
                    limit = {
                        has_building_or_higher = rock_of_gibraltar_01
                        NOT = { has_building = rock_of_gibraltar_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rock_of_gibraltar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rock_of_gibraltar_01
                }
                if = {
                    limit = {
                        has_building_or_higher = roman_wall_of_lugo_01
                        NOT = { has_building = roman_wall_of_lugo_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = roman_wall_of_lugo_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = roman_wall_of_lugo_01
                }
                if = {
                    limit = {
                        has_building_or_higher = royal_armory_01
                        NOT = { has_building = royal_armory_03 }
                    }
                    add_building = royal_armory_03
                }
                if = {
                    limit = {
                        has_building_or_higher = royal_forest_01
                        NOT = { has_building = royal_forest_03 }
                    }
                    add_building = royal_forest_03
                }
                if = {
                    limit = {
                        has_building_or_higher = royal_garden_01
                        NOT = { has_building = royal_garden_03 }
                    }
                    add_building = royal_garden_03
                }
                if = {
                    limit = {
                        has_building_or_higher = rudnik_mines_01
                        NOT = { has_building = rudnik_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = rudnik_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = rudnik_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = sacred_pool_01
                        NOT = { has_building = sacred_pool_08 }
                    }
                    add_building = sacred_pool_08
                }
                if = {
                    limit = {
                        has_building_or_higher = sado_mines_01
                        NOT = { has_building = sado_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sado_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sado_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = saint_catherine
                        NOT = { has_building = saint_catherine }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = saint_catherine
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = saint_catherine
                }
                if = {
                    limit = {
                        has_building_or_higher = saint_lazarus
                        NOT = { has_building = saint_lazarus }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = saint_lazarus
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = saint_lazarus
                }
                if = {
                    limit = {
                        has_building_or_higher = sanchi_stupa_01
                        NOT = { has_building = sanchi_stupa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sanchi_stupa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sanchi_stupa_01
                }
                if = {
                    limit = {
                        has_building_or_higher = sankore_university
                        NOT = { has_building = sankore_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sankore_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sankore_university
                }
                if = {
                    limit = {
                        has_building_or_higher = sar_i_sang_mines_01
                        NOT = { has_building = sar_i_sang_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sar_i_sang_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sar_i_sang_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = schwaz_mines_01
                        NOT = { has_building = schwaz_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = schwaz_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = schwaz_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = scriptorium_01
                        NOT = { has_building = scriptorium_08 }
                    }
                    add_building = scriptorium_08
                }
                if = {
                    limit = {
                        has_building_or_higher = shah_i_zinda_01
                        NOT = { has_building = shah_i_zinda_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shah_i_zinda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shah_i_zinda_02
                }
                if = {
                    limit = {
                        has_building_or_higher = shaolin_monastery_01
                        NOT = { has_building = shaolin_monastery_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shaolin_monastery_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shaolin_monastery_01
                }
                if = {
                    limit = {
                        has_building_or_higher = shigu_academy_01
                        NOT = { has_building = shigu_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shigu_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shigu_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = shwedagon_pagoda_01
                        NOT = { has_building = shwedagon_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = shwedagon_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = shwedagon_pagoda_01
                }
                if = {
                    limit = {
                        has_building_or_higher = siderokausia_mines_01
                        NOT = { has_building = siderokausia_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siderokausia_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siderokausia_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = siege_works_01
                        NOT = { has_building = siege_works_03 }
                    }
                    add_building = siege_works_03
                }
                if = {
                    limit = {
                        has_building_or_higher = siena_university
                        NOT = { has_building = siena_university }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = siena_university
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = siena_university
                }
                if = {
                    limit = {
                        has_building_or_higher = smiths_01
                        NOT = { has_building = smiths_08 }
                    }
                    add_building = smiths_08
                }
                if = {
                    limit = {
                        has_building_or_higher = sofia_ohrid
                        NOT = { has_building = sofia_ohrid }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sofia_ohrid
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sofia_ohrid
                }
                if = {
                    limit = {
                        has_building_or_higher = soltaniyeh_01
                        NOT = { has_building = soltaniyeh_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = soltaniyeh_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = soltaniyeh_01
                }
                if = {
                    limit = {
                        has_building_or_higher = somapura_university_01
                        NOT = { has_building = somapura_university_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = somapura_university_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = somapura_university_01
                }
                if = {
                    limit = {
                        has_building_or_higher = special_greenhouse_01
                        NOT = { has_building = special_greenhouse_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = special_greenhouse_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = special_greenhouse_01
                }
                if = {
                    limit = {
                        has_building_or_higher = special_sicilian_parliament_01
                        NOT = { has_building = special_sicilian_parliament_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = special_sicilian_parliament_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = special_sicilian_parliament_01
                }
                if = {
                    limit = {
                        has_building_or_higher = spice_plantation_01
                        NOT = { has_building = spice_plantation_08 }
                    }
                    add_building = spice_plantation_08
                }
                if = {
                    limit = {
                        has_building_or_higher = srebrenica_mines_01
                        NOT = { has_building = srebrenica_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = srebrenica_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = srebrenica_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = stables_01
                        NOT = { has_building = stables_08 }
                    }
                    add_building = stables_08
                }
                if = {
                    limit = {
                        has_building_or_higher = stilted_granaries_01
                        NOT = { has_building = stilted_granaries_04 }
                    }
                    add_building = stilted_granaries_04
                }
                if = {
                    limit = {
                        has_building_or_higher = stone_pagoda_01
                        NOT = { has_building = stone_pagoda_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = stone_pagoda_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = stone_pagoda_01
                }
                if = {
                    limit = {
                        has_building_or_higher = stonehenge_01
                        NOT = { has_building = stonehenge_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = stonehenge_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = stonehenge_01
                }
                if = {
                    limit = {
                        has_building_or_higher = sumela_monastery_01
                        NOT = { has_building = sumela_monastery_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sumela_monastery_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sumela_monastery_02
                }
                if = {
                    limit = {
                        has_building_or_higher = sunday_bazaar_01
                        NOT = { has_building = sunday_bazaar_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = sunday_bazaar_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = sunday_bazaar_02
                }
                if = {
                    limit = {
                        has_building_or_higher = suvarnadvipa_mines_01
                        NOT = { has_building = suvarnadvipa_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suvarnadvipa_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suvarnadvipa_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = suwalesi_megaliths_01
                        NOT = { has_building = suwalesi_megaliths_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = suwalesi_megaliths_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = suwalesi_megaliths_01
                }
                if = {
                    limit = {
                        has_building_or_higher = swahili_port_lamu
                        NOT = { has_building = swahili_port_lamu }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_lamu
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_lamu
                }
                if = {
                    limit = {
                        has_building_or_higher = swahili_port_mombasa
                        NOT = { has_building = swahili_port_mombasa }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_mombasa
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_mombasa
                }
                if = {
                    limit = {
                        has_building_or_higher = swahili_port_pate
                        NOT = { has_building = swahili_port_pate }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_pate
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_pate
                }
                if = {
                    limit = {
                        has_building_or_higher = swahili_port_pemba
                        NOT = { has_building = swahili_port_pemba }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_pemba
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_pemba
                }
                if = {
                    limit = {
                        has_building_or_higher = swahili_port_zanzibar
                        NOT = { has_building = swahili_port_zanzibar }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = swahili_port_zanzibar
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = swahili_port_zanzibar
                }
                if = {
                    limit = {
                        has_building_or_higher = tada_mines_01
                        NOT = { has_building = tada_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tada_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tada_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = taghaza_mines_01
                        NOT = { has_building = taghaza_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = taghaza_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = taghaza_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = takkeda_mines_01
                        NOT = { has_building = takkeda_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = takkeda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = takkeda_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = tax_assessor_01
                        NOT = { has_building = tax_assessor_03 }
                    }
                    add_building = tax_assessor_03
                }
                if = {
                    limit = {
                        has_building_or_higher = temple_01
                        NOT = { has_building = temple_04 }
                    }
                    add_building = temple_04
                }
                if = {
                    limit = {
                        has_building_or_higher = temple_citadel_01
                        NOT = { has_building = temple_citadel_04 }
                    }
                    add_building = temple_citadel_04
                }
                if = {
                    limit = {
                        has_building_or_higher = temple_of_uppsala_01
                        NOT = { has_building = temple_of_uppsala_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temple_of_uppsala_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temple_of_uppsala_02
                }
                if = {
                    limit = {
                        has_building_or_higher = temples_angkor_01
                        NOT = { has_building = temples_angkor_02 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = temples_angkor_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = temples_angkor_02
                }
                if = {
                    limit = {
                        has_building_or_higher = the_colosseum_01
                        NOT = { has_building = the_colosseum_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_colosseum_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_colosseum_01
                }
                if = {
                    limit = {
                        has_building_or_higher = the_friday_mosque_01
                        NOT = { has_building = the_friday_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_friday_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_friday_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = the_great_wall_01
                        NOT = { has_building = the_great_wall_04 }
                    }
                    add_building = the_great_wall_04
                }
                if = {
                    limit = {
                        has_building_or_higher = the_great_wall_liaodong
                        NOT = { has_building = the_great_wall_liaodong }
                    }
                    add_building = the_great_wall_liaodong
                }
                if = {
                    limit = {
                        has_building_or_higher = the_great_wall_shanhai_pass
                        NOT = { has_building = the_great_wall_shanhai_pass }
                    }
                    add_building = the_great_wall_shanhai_pass
                }
                if = {
                    limit = {
                        has_building_or_higher = the_pyramids_01
                        NOT = { has_building = the_pyramids_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_pyramids_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_pyramids_01
                }
                if = {
                    limit = {
                        has_building_or_higher = the_tower_of_london_01
                        NOT = { has_building = the_tower_of_london_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = the_tower_of_london_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = the_tower_of_london_01
                }
                if = {
                    limit = {
                        has_building_or_higher = theodosian_walls_01
                        NOT = { has_building = theodosian_walls_01 }
                    }
                    add_building = theodosian_walls_01
                }
                if = {
                    limit = {
                        has_building_or_higher = three_pagodas_dali_01
                        NOT = { has_building = three_pagodas_dali_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = three_pagodas_dali_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = three_pagodas_dali_01
                }
                if = {
                    limit = {
                        has_building_or_higher = thuriang_kilns_01
                        NOT = { has_building = thuriang_kilns_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = thuriang_kilns_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = thuriang_kilns_01
                }
                if = {
                    limit = {
                        has_building_or_higher = tiantai_monasteries_01
                        NOT = { has_building = tiantai_monasteries_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tiantai_monasteries_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tiantai_monasteries_01
                }
                if = {
                    limit = {
                        has_building_or_higher = tomb_of_cyrus_01
                        NOT = { has_building = tomb_of_cyrus_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tomb_of_cyrus_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tomb_of_cyrus_01
                }
                if = {
                    limit = {
                        has_building_or_higher = tower_of_hercules_01
                        NOT = { has_building = tower_of_hercules_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tower_of_hercules_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tower_of_hercules_01
                }
                if = {
                    limit = {
                        has_building_or_higher = tower_of_silence_01
                        NOT = { has_building = tower_of_silence_01 }
                    }
                    add_building = tower_of_silence_01
                }
                if = {
                    limit = {
                        has_building_or_higher = trepca_mines_01
                        NOT = { has_building = trepca_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trepca_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trepca_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = tribe_01
                        NOT = { has_building = tribe_02 }
                    }
                    add_building = tribe_02
                }
                if = {
                    limit = {
                        has_building_or_higher = trosky_castle_01
                        NOT = { has_building = trosky_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = trosky_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = trosky_castle_01
                }
                if = {
                    limit = {
                        has_building_or_higher = tsushima_mines_01
                        NOT = { has_building = tsushima_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = tsushima_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = tsushima_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = turda_mines_01
                        NOT = { has_building = turda_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = turda_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = turda_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = vatapi_caves_01
                        NOT = { has_building = vatapi_caves_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = vatapi_caves_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = vatapi_caves_01
                }
                if = {
                    limit = {
                        has_building_or_higher = verespatak_mines_01
                        NOT = { has_building = verespatak_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = verespatak_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = verespatak_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = vihara_halls_01
                        NOT = { has_building = vihara_halls_08 }
                    }
                    add_building = vihara_halls_08
                }
                if = {
                    limit = {
                        has_building_or_higher = visby_ringmur_01
                        NOT = { has_building = visby_ringmur_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = visby_ringmur_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = visby_ringmur_01
                }
                if = {
                    limit = {
                        has_building_or_higher = visegrad_castle_01
                        NOT = { has_building = visegrad_castle_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = visegrad_castle_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = visegrad_castle_01
                }
                if = {
                    limit = {
                        has_building_or_higher = walls_00
                        NOT = { has_building = walls_04 }
                    }
                    add_building = walls_04
                }
                if = {
                    limit = {
                        has_building_or_higher = walls_01_tribal
                        NOT = { has_building = walls_01_tribal }
                    }
                    add_building = walls_01_tribal
                }
                if = {
                    limit = {
                        has_building_or_higher = walls_of_benin_01
                        NOT = { has_building = walls_of_benin_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = walls_of_benin_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = walls_of_benin_01
                }
                if = {
                    limit = {
                        has_building_or_higher = walls_of_genoa_01
                        NOT = { has_building = walls_of_genoa_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = walls_of_genoa_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = walls_of_genoa_01
                }
                if = {
                    limit = {
                        has_building_or_higher = wantilan_01
                        NOT = { has_building = wantilan_04 }
                    }
                    add_building = wantilan_04
                }
                if = {
                    limit = {
                        has_building_or_higher = war_camps_01
                        NOT = { has_building = war_camps_02 }
                    }
                    add_building = war_camps_02
                }
                if = {
                    limit = {
                        has_building_or_higher = warrior_lodges_01
                        NOT = { has_building = warrior_lodges_08 }
                    }
                    add_building = warrior_lodges_08
                }
                if = {
                    limit = {
                        has_building_or_higher = wartburg_01
                        NOT = { has_building = wartburg_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wartburg_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wartburg_01
                }
                if = {
                    limit = {
                        has_building_or_higher = watchtowers_01
                        NOT = { has_building = watchtowers_08 }
                    }
                    add_building = watchtowers_08
                }
                if = {
                    limit = {
                        has_building_or_higher = water_temples_01
                        NOT = { has_building = water_temples_04 }
                    }
                    add_building = water_temples_04
                }
                if = {
                    limit = {
                        has_building_or_higher = watermills_01
                        NOT = { has_building = watermills_08 }
                    }
                    add_building = watermills_08
                }
                if = {
                    limit = {
                        has_building_or_higher = waterworks_01
                        NOT = { has_building = waterworks_08 }
                    }
                    add_building = waterworks_08
                }
                if = {
                    limit = {
                        has_building_or_higher = wawel_cathedral_01
                        NOT = { has_building = wawel_cathedral_03 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wawel_cathedral_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wawel_cathedral_03
                }
                if = {
                    limit = {
                        has_building_or_higher = white_deer_grotto_academy_01
                        NOT = { has_building = white_deer_grotto_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = white_deer_grotto_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = white_deer_grotto_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = wilwatikta_palace_01
                        NOT = { has_building = wilwatikta_palace_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wilwatikta_palace_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wilwatikta_palace_01
                }
                if = {
                    limit = {
                        has_building_or_higher = wind_furnace_01
                        NOT = { has_building = wind_furnace_08 }
                    }
                    add_building = wind_furnace_08
                }
                if = {
                    limit = {
                        has_building_or_higher = windmills_01
                        NOT = { has_building = windmills_08 }
                    }
                    add_building = windmills_08
                }
                if = {
                    limit = {
                        has_building_or_higher = workshops_01
                        NOT = { has_building = workshops_08 }
                    }
                    add_building = workshops_08
                }
                if = {
                    limit = {
                        has_building_or_higher = wudang_mountain_temples_01
                        NOT = { has_building = wudang_mountain_temples_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wudang_mountain_temples_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wudang_mountain_temples_01
                }
                if = {
                    limit = {
                        has_building_or_higher = wulingyuan_01
                        NOT = { has_building = wulingyuan_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = wulingyuan_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = wulingyuan_01
                }
                if = {
                    limit = {
                        has_building_or_higher = xiuyan_mines_01
                        NOT = { has_building = xiuyan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = xiuyan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = xiuyan_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = yazd_mosque_01
                        NOT = { has_building = yazd_mosque_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yazd_mosque_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yazd_mosque_01
                }
                if = {
                    limit = {
                        has_building_or_higher = york_walls_01
                        NOT = { has_building = york_walls_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = york_walls_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = york_walls_01
                }
                if = {
                    limit = {
                        has_building_or_higher = yuelu_academy_01
                        NOT = { has_building = yuelu_academy_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yuelu_academy_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yuelu_academy_01
                }
                if = {
                    limit = {
                        has_building_or_higher = yungang_grottoes_01
                        NOT = { has_building = yungang_grottoes_01 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = yungang_grottoes_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = yungang_grottoes_01
                }
                if = {
                    limit = {
                        has_building_or_higher = zawar_mines_01
                        NOT = { has_building = zawar_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zawar_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zawar_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = zigong_mines_01
                        NOT = { has_building = zigong_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zigong_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zigong_mines_04
                }
                if = {
                    limit = {
                        has_building_or_higher = zijinshan_mines_01
                        NOT = { has_building = zijinshan_mines_04 }
                    }
                    if = {
                        limit = { has_special_building_slot = no }
                        add_special_building_slot = zijinshan_mines_01
                    }
                    DI_clear_special_building_effect = yes
                    add_special_building = zijinshan_mines_04
                }
            }
        }
    }
}
