﻿### ARMY SPAWNING EFFECTS ###
DI_army_spawner_add_increment = {
    scope = character

    is_valid = {
        any_owned_story = {
            story_type = DI_misc_variables_story
            var:DI_army_spawner_increment_value < 1000000
        }
    }

    effect = {
        random_owned_story = {
            limit = {
                story_type = DI_misc_variables_story
            }
            save_scope_as = DI_story
        }
        scope:DI_story = {
            # if less than 1 million and greater than 100000 add 100000
            if = {
                limit = {
                    var:DI_army_spawner_increment_value >= 100000
                    var:DI_army_spawner_increment_value < 1000000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 100000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value >= 100000
                    var:DI_army_spawner_increment_value < 1000000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 10000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 100000
                    var:DI_army_spawner_increment_value >= 10000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 5000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 10000
                    var:DI_army_spawner_increment_value >= 5000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 1000
                }
            }
            # else if <= 5000 and > 500 add 500
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 5000
                    var:DI_army_spawner_increment_value >= 500
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 500
                }
            }
            # else if <= 500 and > 100 add 100
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 500
                    var:DI_army_spawner_increment_value >= 100
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 100
                }
            }
            # else if <= 100 and > 10 add 10
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 100
                    var:DI_army_spawner_increment_value >= 10
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 10
                }
            }
            # else if <= 10 and > 1 add 1
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value < 10
                    var:DI_army_spawner_increment_value >= 1
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    add = 1
                }
            }
        }
    }
}

DI_army_spawner_subtract_increment = {
    scope = character

    is_valid = {
        any_owned_story = {
            story_type = DI_misc_variables_story
            var:DI_army_spawner_increment_value > 1
        }
    }

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

        scope:DI_story = {
            # if greater than 100000 subtract 100000
            if = {
                limit = {
                    var:DI_army_spawner_increment_value > 100000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 100000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value > 50000
                    var:DI_army_spawner_increment_value <= 100000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 10000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 50000
                    var:DI_army_spawner_increment_value > 10000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 5000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 10000
                    var:DI_army_spawner_increment_value > 5000
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 1000
                }
            }
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 5000
                    var:DI_army_spawner_increment_value > 500
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 500
                }
            }
            # else if <= 500 and > 100 subtract 100
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 500
                    var:DI_army_spawner_increment_value > 100
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 100
                }
            }
            # else if <= 100 and > 10 subtract 10
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 100
                    var:DI_army_spawner_increment_value > 10
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 10
                }
            }
            # else if <= 10 and > 1 subtract 1
            else_if = {
                limit = {
                    var:DI_army_spawner_increment_value <= 10
                    var:DI_army_spawner_increment_value > 1
                }
                change_variable = {
                    name = DI_army_spawner_increment_value
                    subtract = 1
                }
            }
        }
    }
}

### BASIC MAA ###
### Levy ###
DI_levy_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    levies = scope:DI_story.var:DI_army_spawner_increment_value

                    location = scope:target.location

                    inheritable = no

                    name = game_concept_levies
                }
            }
        }
        else = {
            spawn_army = {
                levies = scope:DI_story.var:DI_army_spawner_increment_value

                location = root.location

                inheritable = no

                name = game_concept_levies
            }
        }
    }
}

# AUTO-GENERATED Men-at-Arms scripted_guis — do not edit by hand
# One spawner effect per MAA key

### Huscarl Spawner
DI_huscarl_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = huscarl
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = huscarl
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = huscarl
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = huscarl
            }
        }
    }
}

### Landsknecht Spawner
DI_landsknecht_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = landsknecht
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = landsknecht
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = landsknecht
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = landsknecht
            }
        }
    }
}

### Longbowmen Spawner
DI_longbowmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = longbowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = longbowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = longbowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = longbowmen
            }
        }
    }
}

### Goedendag Spawner
DI_goedendag_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = goedendag
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = goedendag
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = goedendag
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = goedendag
            }
        }
    }
}

### Gendarme Spawner
DI_gendarme_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = gendarme
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = gendarme
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = gendarme
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = gendarme
            }
        }
    }
}

### Chasseur Spawner
DI_chasseur_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = chasseur
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = chasseur
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = chasseur
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = chasseur
            }
        }
    }
}

### Picchieri Spawner
DI_picchieri_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = picchieri
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = picchieri
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = picchieri
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = picchieri
            }
        }
    }
}

### Praetorian Spawner
DI_praetorian_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = praetorian
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = praetorian
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = praetorian
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = praetorian
            }
        }
    }
}

### Caballero Spawner
DI_caballero_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = caballero
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = caballero
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = caballero
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = caballero
            }
        }
    }
}

### Monaspa Spawner
DI_monaspa_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = monaspa
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = monaspa
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = monaspa
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = monaspa
            }
        }
    }
}

### Cataphract Spawner
DI_cataphract_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = cataphract
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cataphract
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cataphract
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cataphract
            }
        }
    }
}

### Hobelar Spawner
DI_hobelar_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = hobelar
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = hobelar
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = hobelar
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = hobelar
            }
        }
    }
}

### Schiltron Spawner
DI_schiltron_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = schiltron
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = schiltron
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = schiltron
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = schiltron
            }
        }
    }
}

### Metsanvartija Spawner
DI_metsanvartija_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = metsanvartija
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = metsanvartija
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = metsanvartija
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = metsanvartija
            }
        }
    }
}

### Horse Archers Spawner
DI_horse_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = horse_archers
            }
        }
    }
}

### Ayyar Spawner
DI_ayyar_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = ayyar
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ayyar
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ayyar
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ayyar
            }
        }
    }
}

### Mubarizun Spawner
DI_mubarizun_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = mubarizun
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mubarizun
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mubarizun
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mubarizun
            }
        }
    }
}

### Mulaththamun Spawner
DI_mulaththamun_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = mulaththamun
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mulaththamun
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mulaththamun
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mulaththamun
            }
        }
    }
}

### Archers Of The Nile Spawner
DI_archers_of_the_nile_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = archers_of_the_nile
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = archers_of_the_nile
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = archers_of_the_nile
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = archers_of_the_nile
            }
        }
    }
}

### Paiks Spawner
DI_paiks_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = paiks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = paiks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = paiks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = paiks
            }
        }
    }
}

### Druzhina Spawner
DI_druzhina_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = druzhina
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = druzhina
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = druzhina
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = druzhina
            }
        }
    }
}

### Hussar Spawner
DI_hussar_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = hussar
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = hussar
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = hussar
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = hussar
            }
        }
    }
}

### Horn Warrior Spawner
DI_horn_warrior_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = horn_warrior
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = horn_warrior
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = horn_warrior
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = horn_warrior
            }
        }
    }
}

### Bush Hunter Spawner
DI_bush_hunter_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = bush_hunter
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bush_hunter
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bush_hunter
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bush_hunter
            }
        }
    }
}

### Shomer Spawner
DI_shomer_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = shomer
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = shomer
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = shomer
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = shomer
            }
        }
    }
}

### Garudas Spawner
DI_garudas_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = garudas
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = garudas
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = garudas
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = garudas
            }
        }
    }
}

### Khandayat Spawner
DI_khandayat_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = khandayat
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = khandayat
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = khandayat
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = khandayat
            }
        }
    }
}

### Mountaineer Spawner
DI_mountaineer_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = mountaineer
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mountaineer
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mountaineer
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mountaineer
            }
        }
    }
}

### Sahel Horsemen Spawner
DI_sahel_horsemen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = sahel_horsemen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sahel_horsemen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sahel_horsemen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sahel_horsemen
            }
        }
    }
}

### Guinea Warrior Spawner
DI_guinea_warrior_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = guinea_warrior
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = guinea_warrior
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = guinea_warrior
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = guinea_warrior
            }
        }
    }
}

### Sarawit Spawner
DI_sarawit_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = sarawit
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sarawit
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sarawit
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sarawit
            }
        }
    }
}

### Abudrar Spawner
DI_abudrar_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = abudrar
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = abudrar
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = abudrar
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = abudrar
            }
        }
    }
}

### Zbrojnosh Spawner
DI_zbrojnosh_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = zbrojnosh
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = zbrojnosh
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = zbrojnosh
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = zbrojnosh
            }
        }
    }
}

### Palace Guards Spawner
DI_palace_guards_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = palace_guards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = palace_guards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = palace_guards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = palace_guards
            }
        }
    }
}

### Shenbigong Spawner
DI_shenbigong_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = shenbigong
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = shenbigong
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = shenbigong
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = shenbigong
            }
        }
    }
}

### Guanch Vaulter Spawner
DI_guanch_vaulter_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = guanch_vaulter
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = guanch_vaulter
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = guanch_vaulter
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = guanch_vaulter
            }
        }
    }
}

### Asawira Spawner
DI_asawira_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = asawira
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = asawira
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = asawira
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = asawira
            }
        }
    }
}

### Tarkhan Spawner
DI_tarkhan_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = tarkhan
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = tarkhan
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = tarkhan
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = tarkhan
            }
        }
    }
}

### Zupin Warrior Spawner
DI_zupin_warrior_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = zupin_warrior
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = zupin_warrior
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = zupin_warrior
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = zupin_warrior
            }
        }
    }
}

### Tawashi Spawner
DI_tawashi_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = tawashi
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = tawashi
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = tawashi
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = tawashi
            }
        }
    }
}

### Teutonic Knights Spawner
DI_teutonic_knights_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = teutonic_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = teutonic_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = teutonic_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = teutonic_knights
            }
        }
    }
}

### Light Footmen Spawner
DI_light_footmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = light_footmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = light_footmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = light_footmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = light_footmen
            }
        }
    }
}

### Bowmen Spawner
DI_bowmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = bowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bowmen
            }
        }
    }
}

### Light Horsemen Spawner
DI_light_horsemen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = light_horsemen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = light_horsemen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = light_horsemen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = light_horsemen
            }
        }
    }
}

### Pikemen Unit Spawner
DI_pikemen_unit_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = pikemen_unit
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = pikemen_unit
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = pikemen_unit
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = pikemen_unit
            }
        }
    }
}

### Armored Footmen Spawner
DI_armored_footmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = armored_footmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = armored_footmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = armored_footmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = armored_footmen
            }
        }
    }
}

### Onager Spawner
DI_onager_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = onager
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = onager
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = onager
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = onager
            }
        }
    }
}

### Armored Horsemen Spawner
DI_armored_horsemen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = armored_horsemen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = armored_horsemen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = armored_horsemen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = armored_horsemen
            }
        }
    }
}

### Mangonel Spawner
DI_mangonel_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = mangonel
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mangonel
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mangonel
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mangonel
            }
        }
    }
}

### Crossbowmen Spawner
DI_crossbowmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = crossbowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = crossbowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = crossbowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = crossbowmen
            }
        }
    }
}

### Trebuchet Spawner
DI_trebuchet_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = trebuchet
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = trebuchet
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = trebuchet
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = trebuchet
            }
        }
    }
}

### Bombard Spawner
DI_bombard_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = bombard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bombard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bombard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bombard
            }
        }
    }
}

### Handgunners Spawner
DI_handgunners_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = handgunners
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = handgunners
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = handgunners
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = handgunners
            }
        }
    }
}

### House Guard Spawner
DI_house_guard_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = house_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = house_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = house_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = house_guard
            }
        }
    }
}

### Pikemen Militia Spawner
DI_pikemen_militia_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = pikemen_militia
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = pikemen_militia
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = pikemen_militia
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = pikemen_militia
            }
        }
    }
}

### Camel Rider Spawner
DI_camel_rider_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = camel_rider
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = camel_rider
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = camel_rider
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = camel_rider
            }
        }
    }
}

### War Elephant Spawner
DI_war_elephant_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = war_elephant
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = war_elephant
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = war_elephant
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = war_elephant
            }
        }
    }
}

### Accolade Maa Archers Spawner
DI_accolade_maa_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_archers
            }
        }
    }
}

### Accolade Maa Skirmishers Spawner
DI_accolade_maa_skirmishers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_skirmishers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_skirmishers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_skirmishers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_skirmishers
            }
        }
    }
}

### Accolade Maa Pikes Spawner
DI_accolade_maa_pikes_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_pikes
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_pikes
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_pikes
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_pikes
            }
        }
    }
}

### Accolade Maa Outriders Spawner
DI_accolade_maa_outriders_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_outriders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_outriders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_outriders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_outriders
            }
        }
    }
}

### Accolade Maa Vanguards Spawner
DI_accolade_maa_vanguards_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_vanguards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_vanguards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_vanguards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_vanguards
            }
        }
    }
}

### Accolade Maa Lancers Spawner
DI_accolade_maa_lancers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_lancers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_lancers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_lancers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_lancers
            }
        }
    }
}

### Accolade Maa Crossbowers Spawner
DI_accolade_maa_crossbowers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_crossbowers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_crossbowers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_crossbowers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_crossbowers
            }
        }
    }
}

### Accolade Maa Cameliers Spawner
DI_accolade_maa_cameliers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_cameliers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_cameliers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_cameliers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_cameliers
            }
        }
    }
}

### Accolade Maa Elephantiers Spawner
DI_accolade_maa_elephantiers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_elephantiers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_elephantiers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_elephantiers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_elephantiers
            }
        }
    }
}

### Accolade Maa Horse Archers Spawner
DI_accolade_maa_horse_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_horse_archers
            }
        }
    }
}

### Accolade Maa Handgunners Spawner
DI_accolade_maa_handgunners_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = accolade_maa_handgunners
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = accolade_maa_handgunners
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = accolade_maa_handgunners
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = accolade_maa_handgunners
            }
        }
    }
}

### Vigmen Spawner
DI_vigmen_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = vigmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = vigmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = vigmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = vigmen
            }
        }
    }
}

### Bondi Spawner
DI_bondi_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = bondi
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bondi
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bondi
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bondi
            }
        }
    }
}

### Varangian Veterans Spawner
DI_varangian_veterans_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = varangian_veterans
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = varangian_veterans
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = varangian_veterans
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = varangian_veterans
            }
        }
    }
}

### Jomsviking Pirates Spawner
DI_jomsviking_pirates_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = jomsviking_pirates
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = jomsviking_pirates
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = jomsviking_pirates
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = jomsviking_pirates
            }
        }
    }
}

### Ayrudzi Spawner
DI_ayrudzi_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = ayrudzi
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ayrudzi
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ayrudzi
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ayrudzi
            }
        }
    }
}

### Conrois Spawner
DI_conrois_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = conrois
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = conrois
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = conrois
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = conrois
            }
        }
    }
}

### Akritai Spawner
DI_akritai_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = akritai
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = akritai
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = akritai
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = akritai
            }
        }
    }
}

### Ballistrai Spawner
DI_ballistrai_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = ballistrai
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ballistrai
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ballistrai
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ballistrai
            }
        }
    }
}

### Skoutatoi Spawner
DI_skoutatoi_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = skoutatoi
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = skoutatoi
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = skoutatoi
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = skoutatoi
            }
        }
    }
}

### Varangian Guards Spawner
DI_varangian_guards_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = varangian_guards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = varangian_guards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = varangian_guards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = varangian_guards
            }
        }
    }
}

### Handpicked Faithful Spawner
DI_handpicked_faithful_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = handpicked_faithful
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = handpicked_faithful
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = handpicked_faithful
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = handpicked_faithful
            }
        }
    }
}

### Maa Bandits Spawner
DI_maa_bandits_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = maa_bandits
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = maa_bandits
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = maa_bandits
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = maa_bandits
            }
        }
    }
}

### Maa Poachers Spawner
DI_maa_poachers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = maa_poachers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = maa_poachers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = maa_poachers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = maa_poachers
            }
        }
    }
}

### Maa Marauders Spawner
DI_maa_marauders_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = maa_marauders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = maa_marauders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = maa_marauders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = maa_marauders
            }
        }
    }
}

### Maa Thieves Spawner
DI_maa_thieves_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = maa_thieves
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = maa_thieves
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = maa_thieves
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = maa_thieves
            }
        }
    }
}

### Nomadic Riders Spawner
DI_nomadic_riders_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = nomadic_riders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = nomadic_riders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = nomadic_riders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = nomadic_riders
            }
        }
    }
}

### Torch Bearers Spawner
DI_torch_bearers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = torch_bearers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = torch_bearers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = torch_bearers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = torch_bearers
            }
        }
    }
}

### Kheshig Spawner
DI_kheshig_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = kheshig
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = kheshig
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = kheshig
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = kheshig
            }
        }
    }
}

### Steppe Raiders Spawner
DI_steppe_raiders_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = steppe_raiders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = steppe_raiders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = steppe_raiders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = steppe_raiders
            }
        }
    }
}

### Heavy Horse Archers Spawner
DI_heavy_horse_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = heavy_horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = heavy_horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = heavy_horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = heavy_horse_archers
            }
        }
    }
}

### Nomad Lancers Spawner
DI_nomad_lancers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = nomad_lancers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = nomad_lancers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = nomad_lancers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = nomad_lancers
            }
        }
    }
}

### Mangudai Spawner
DI_mangudai_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = mangudai
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mangudai
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mangudai
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mangudai
            }
        }
    }
}

### Cataphract Archers Spawner
DI_cataphract_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = cataphract_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cataphract_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cataphract_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cataphract_archers
            }
        }
    }
}

### Maturkan Warriors Spawner
DI_maturkan_warriors_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = maturkan_warriors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = maturkan_warriors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = maturkan_warriors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = maturkan_warriors
            }
        }
    }
}

### Emishi Horse Archers Spawner
DI_emishi_horse_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = emishi_horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = emishi_horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = emishi_horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = emishi_horse_archers
            }
        }
    }
}

### Japanese Horse Archers Spawner
DI_japanese_horse_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = japanese_horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = japanese_horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = japanese_horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = japanese_horse_archers
            }
        }
    }
}

### Warrior Monks Spawner
DI_warrior_monks_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = warrior_monks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = warrior_monks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = warrior_monks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = warrior_monks
            }
        }
    }
}

### Fire Lancers Spawner
DI_fire_lancers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = fire_lancers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = fire_lancers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = fire_lancers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = fire_lancers
            }
        }
    }
}

### Gakgung Archers Spawner
DI_gakgung_archers_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = gakgung_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = gakgung_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = gakgung_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = gakgung_archers
            }
        }
    }
}

### Ballista Elephant Spawner
DI_ballista_elephant_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = ballista_elephant
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ballista_elephant
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ballista_elephant
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ballista_elephant
            }
        }
    }
}

### Pesilat Warriors Spawner
DI_pesilat_warriors_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = pesilat_warriors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = pesilat_warriors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = pesilat_warriors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = pesilat_warriors
            }
        }
    }
}

### Samurai Spawner
DI_samurai_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = samurai
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = samurai
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = samurai
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = samurai
            }
        }
    }
}

### Zhanmadao Infantry Spawner
DI_zhanmadao_infantry_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = zhanmadao_infantry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = zhanmadao_infantry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = zhanmadao_infantry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = zhanmadao_infantry
            }
        }
    }
}

### Tiefutu Spawner
DI_tiefutu_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = tiefutu
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = tiefutu
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = tiefutu
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = tiefutu
            }
        }
    }
}

### Burenjia Spawner
DI_burenjia_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = burenjia
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = burenjia
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = burenjia
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = burenjia
            }
        }
    }
}

### Rocket Carts Spawner
DI_rocket_carts_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = rocket_carts
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = rocket_carts
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = rocket_carts
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = rocket_carts
            }
        }
    }
}

### Ballista Spawner
DI_ballista_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = ballista
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ballista
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ballista
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ballista
            }
        }
    }
}

### Cloud Ladder Spawner
DI_cloud_ladder_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = cloud_ladder
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cloud_ladder
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cloud_ladder
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cloud_ladder
            }
        }
    }
}

### Siege Tower Spawner
DI_siege_tower_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = siege_tower
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = siege_tower
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = siege_tower
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = siege_tower
            }
        }
    }
}

### Cannon Spawner
DI_cannon_effect = {
    scope = character

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

        if = {
            limit = {
                scope:DI_story = { has_variable = DI_pinned_char_var }
            }
            every_living_character = {
                limit = { has_character_flag = pinned_for_edit }
                save_scope_as = target

                spawn_army = {
                    men_at_arms = {
                        type = cannon
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cannon
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cannon
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cannon
            }
        }
    }
}
