﻿### 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 = {
				limit = {
					var:DI_army_spawner_increment_value >= 50000
				}
				change_variable = {
					name = DI_army_spawner_increment_value
					add = 10000
				}
			}
			else_if = {
				limit = {
					AND = {
						var:DI_army_spawner_increment_value < 50000
						var:DI_army_spawner_increment_value >= 10000
					}
				}
				change_variable = {
					name = DI_army_spawner_increment_value
							add = 5000
				}
			}
			else_if = {
				limit = {
					AND = {
						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 = {
				change_variable = {
					name = DI_army_spawner_increment_value
					add = 500
				}
			}
		}
    }
}

DI_army_spawner_subtract_increment = {
	scope = character
	
	is_valid = {
		any_owned_story = {
			story_type = DI_misc_variables_story
			var:DI_army_spawner_increment_value > 500
		}
	}

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

		scope:DI_story = {
			if = {
				limit = {
					var:DI_army_spawner_increment_value > 50000
				}
				change_variable = {
					name = DI_army_spawner_increment_value
					subtract = 10000
				}
			}
			else_if = {
				limit = {
					AND = {
						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 = {
					AND = {
						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 = {
				change_variable = {
					name = DI_army_spawner_increment_value
					subtract = 500
				}
			}
		}
    }
}

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

### Slave Legion Spawner
DI_slave_legion_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 = slave_legion
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = slave_legion
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = slave_legion
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = slave_legion
            }
        }
    }
}

### Tiger Cloaks Spawner
DI_tiger_cloaks_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 = tiger_cloaks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = tiger_cloaks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = tiger_cloaks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = tiger_cloaks
            }
        }
    }
}

### Black Wall Chariots Spawner
DI_black_wall_chariots_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 = black_wall_chariots
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = black_wall_chariots
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = black_wall_chariots
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = black_wall_chariots
            }
        }
    }
}

### Dragonsworn Spawner
DI_dragonsworn_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 = dragonsworn
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = dragonsworn
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = dragonsworn
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = dragonsworn
            }
        }
    }
}

### Demon Guards Spawner
DI_demon_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 = demon_guards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = demon_guards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = demon_guards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = demon_guards
            }
        }
    }
}

### Star Carved Spawner
DI_star_carved_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 = star_carved
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = star_carved
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = star_carved
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = star_carved
            }
        }
    }
}

### Qarlons Fallen Spawner
DI_qarlons_fallen_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 = qarlons_fallen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = qarlons_fallen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = qarlons_fallen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = qarlons_fallen
            }
        }
    }
}

### Smiths Axes Spawner
DI_smiths_axes_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 = smiths_axes
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = smiths_axes
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = smiths_axes
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = smiths_axes
            }
        }
    }
}

### Lockstep Legion Spawner
DI_lockstep_legion_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 = lockstep_legion
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = lockstep_legion
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = lockstep_legion
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = lockstep_legion
            }
        }
    }
}

### Iron Legion Spawner
DI_iron_legion_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 = iron_legion
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = iron_legion
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = iron_legion
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = iron_legion
            }
        }
    }
}

### Market Guard Spawner
DI_market_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 = market_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = market_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = market_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = market_guard
            }
        }
    }
}

### Skahazdahn Wardens Spawner
DI_skahazdahn_wardens_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 = skahazdahn_wardens
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = skahazdahn_wardens
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = skahazdahn_wardens
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = skahazdahn_wardens
            }
        }
    }
}

### Barrow Knights Spawner
DI_barrow_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 = barrow_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = barrow_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = barrow_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = barrow_knights
            }
        }
    }
}

### Marsh Walker Spawner
DI_marsh_walker_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 = marsh_walker
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = marsh_walker
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = marsh_walker
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = marsh_walker
            }
        }
    }
}

### Frog Spears Spawner
DI_frog_spears_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 = frog_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = frog_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = frog_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = frog_spears
            }
        }
    }
}

### Royal Crossbowmen Spawner
DI_royal_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 = royal_crossbowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = royal_crossbowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = royal_crossbowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = royal_crossbowmen
            }
        }
    }
}

### Finger Scouts Spawner
DI_finger_scouts_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 = finger_scouts
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = finger_scouts
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = finger_scouts
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = finger_scouts
            }
        }
    }
}

### Cape Watch Spawner
DI_cape_watch_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 = cape_watch
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cape_watch
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cape_watch
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cape_watch
            }
        }
    }
}

### Green Hand Spawner
DI_green_hand_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 = green_hand
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = green_hand
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = green_hand
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = green_hand
            }
        }
    }
}

### Dragonkeepers Spawner
DI_dragonkeepers_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 = dragonkeepers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = dragonkeepers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = dragonkeepers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = dragonkeepers
            }
        }
    }
}

### Ironborn Reavers Spawner
DI_ironborn_reavers_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 = ironborn_reavers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ironborn_reavers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ironborn_reavers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ironborn_reavers
            }
        }
    }
}

### Marcher Longbowmen Spawner
DI_marcher_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 = marcher_longbowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = marcher_longbowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = marcher_longbowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = marcher_longbowmen
            }
        }
    }
}

### Hunters Of The Moon Spawner
DI_hunters_of_the_moon_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 = hunters_of_the_moon
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = hunters_of_the_moon
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = hunters_of_the_moon
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = hunters_of_the_moon
            }
        }
    }
}

### Stolen Spears Spawner
DI_stolen_spears_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 = stolen_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = stolen_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = stolen_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = stolen_spears
            }
        }
    }
}

### Clan Champions Spawner
DI_clan_champions_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 = clan_champions
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = clan_champions
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = clan_champions
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = clan_champions
            }
        }
    }
}

### Winter Wolves Spawner
DI_winter_wolves_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 = winter_wolves
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = winter_wolves
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = winter_wolves
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = winter_wolves
            }
        }
    }
}

### She Bears Spawner
DI_she_bears_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 = she_bears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = she_bears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = she_bears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = she_bears
            }
        }
    }
}

### Greenblood Oars Spawner
DI_greenblood_oars_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 = greenblood_oars
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = greenblood_oars
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = greenblood_oars
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = greenblood_oars
            }
        }
    }
}

### River Bows Spawner
DI_river_bows_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 = river_bows
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = river_bows
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = river_bows
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = river_bows
            }
        }
    }
}

### Sun Spears Spawner
DI_sun_spears_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 = sun_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sun_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sun_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sun_spears
            }
        }
    }
}

### Sand Steeds Spawner
DI_sand_steeds_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 = sand_steeds
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sand_steeds
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sand_steeds
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sand_steeds
            }
        }
    }
}

### Sistermen Pirates Spawner
DI_sistermen_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 = sistermen_pirates
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sistermen_pirates
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sistermen_pirates
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sistermen_pirates
            }
        }
    }
}

### Unicorn Riders Spawner
DI_unicorn_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 = unicorn_riders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = unicorn_riders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = unicorn_riders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = unicorn_riders
            }
        }
    }
}

### Pass Pikes Spawner
DI_pass_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 = pass_pikes
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = pass_pikes
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = pass_pikes
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = pass_pikes
            }
        }
    }
}

### Storm Knights Spawner
DI_storm_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 = storm_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = storm_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = storm_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = storm_knights
            }
        }
    }
}

### Winged Knights Spawner
DI_winged_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 = winged_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = winged_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = winged_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = winged_knights
            }
        }
    }
}

### Bloody Balesters Spawner
DI_bloody_balesters_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 = bloody_balesters
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bloody_balesters
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bloody_balesters
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bloody_balesters
            }
        }
    }
}

### Sea Snakes Spawner
DI_sea_snakes_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 = sea_snakes
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sea_snakes
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sea_snakes
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sea_snakes
            }
        }
    }
}

### Wolfswood Hunters Spawner
DI_wolfswood_hunters_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 = wolfswood_hunters
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = wolfswood_hunters
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = wolfswood_hunters
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = wolfswood_hunters
            }
        }
    }
}

### Triarchs Herd Spawner
DI_triarchs_herd_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 = triarchs_herd
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = triarchs_herd
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = triarchs_herd
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = triarchs_herd
            }
        }
    }
}

### Bronze Raiders Spawner
DI_bronze_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 = bronze_raiders
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = bronze_raiders
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = bronze_raiders
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = bronze_raiders
            }
        }
    }
}

### Wights Spawner
DI_wights_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 = wights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = wights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = wights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = wights
            }
        }
    }
}

### Purple Sailors Spawner
DI_purple_sailors_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 = purple_sailors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = purple_sailors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = purple_sailors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = purple_sailors
            }
        }
    }
}

### Indentured Legion Spawner
DI_indentured_legion_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 = indentured_legion
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = indentured_legion
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = indentured_legion
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = indentured_legion
            }
        }
    }
}

### Sun Guard Spawner
DI_sun_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 = sun_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sun_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sun_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sun_guard
            }
        }
    }
}

### Moroshi Pikes Spawner
DI_moroshi_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 = moroshi_pikes
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = moroshi_pikes
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = moroshi_pikes
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = moroshi_pikes
            }
        }
    }
}

### Stair Guard Spawner
DI_stair_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 = stair_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = stair_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = stair_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = stair_guard
            }
        }
    }
}

### Cohort Of The Three Thousand Spawner
DI_cohort_of_the_three_thousand_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 = cohort_of_the_three_thousand
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cohort_of_the_three_thousand
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cohort_of_the_three_thousand
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cohort_of_the_three_thousand
            }
        }
    }
}

### Summer Knights Spawner
DI_summer_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 = summer_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = summer_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = summer_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = summer_knights
            }
        }
    }
}

### Honeywine Quirrels Spawner
DI_honeywine_quirrels_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 = honeywine_quirrels
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = honeywine_quirrels
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = honeywine_quirrels
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = honeywine_quirrels
            }
        }
    }
}

### Misty Shields Spawner
DI_misty_shields_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 = misty_shields
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = misty_shields
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = misty_shields
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = misty_shields
            }
        }
    }
}

### Arbor Marines Spawner
DI_arbor_marines_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 = arbor_marines
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = arbor_marines
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = arbor_marines
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = arbor_marines
            }
        }
    }
}

### Mother Sworn Spawner
DI_mother_sworn_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 = mother_sworn
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = mother_sworn
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = mother_sworn
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = mother_sworn
            }
        }
    }
}

### Festival Guards Spawner
DI_festival_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 = festival_guards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = festival_guards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = festival_guards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = festival_guards
            }
        }
    }
}

### Flower Spears Spawner
DI_flower_spears_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 = flower_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = flower_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = flower_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = flower_spears
            }
        }
    }
}

### Green Daggers Spawner
DI_green_daggers_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 = green_daggers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = green_daggers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = green_daggers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = green_daggers
            }
        }
    }
}

### Garden Guard Spawner
DI_garden_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 = garden_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = garden_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = garden_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = garden_guard
            }
        }
    }
}

### Grey Spears Spawner
DI_grey_spears_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 = grey_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = grey_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = grey_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = grey_spears
            }
        }
    }
}

### Elyrian Sailors Spawner
DI_elyrian_sailors_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 = elyrian_sailors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = elyrian_sailors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = elyrian_sailors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = elyrian_sailors
            }
        }
    }
}

### Tolosi Slingers Spawner
DI_tolosi_slingers_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 = tolosi_slingers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = tolosi_slingers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = tolosi_slingers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = tolosi_slingers
            }
        }
    }
}

### Pit Fighters Spawner
DI_pit_fighters_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 = pit_fighters
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = pit_fighters
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = pit_fighters
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = pit_fighters
            }
        }
    }
}

### Collared Bows Spawner
DI_collared_bows_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 = collared_bows
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = collared_bows
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = collared_bows
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = collared_bows
            }
        }
    }
}

### Unsullied Spawner
DI_unsullied_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 = unsullied
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = unsullied
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = unsullied
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = unsullied
            }
        }
    }
}

### Disputant Scouts Spawner
DI_disputant_scouts_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 = disputant_scouts
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = disputant_scouts
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = disputant_scouts
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = disputant_scouts
            }
        }
    }
}

### Weeping Guard Spawner
DI_weeping_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 = weeping_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = weeping_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = weeping_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = weeping_guard
            }
        }
    }
}

### Myrish Crossbows Spawner
DI_myrish_crossbows_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 = myrish_crossbows
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = myrish_crossbows
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = myrish_crossbows
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = myrish_crossbows
            }
        }
    }
}

### Ornate Helms Spawner
DI_ornate_helms_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 = ornate_helms
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ornate_helms
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ornate_helms
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ornate_helms
            }
        }
    }
}

### Scorpions Spawner
DI_scorpions_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 = scorpions
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = scorpions
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = scorpions
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = scorpions
            }
        }
    }
}

### Water Wizards Spawner
DI_water_wizards_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 = water_wizards
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = water_wizards
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = water_wizards
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = water_wizards
            }
        }
    }
}

### Dragons Regiment Spawner
DI_dragons_regiment_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 = dragons_regiment
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = dragons_regiment
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = dragons_regiment
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = dragons_regiment
            }
        }
    }
}

### Poorfellow Skirmishers Spawner
DI_poorfellow_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 = poorfellow_skirmishers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = poorfellow_skirmishers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = poorfellow_skirmishers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = poorfellow_skirmishers
            }
        }
    }
}

### Warriors Sons Heavy Infantry Spawner
DI_warriors_sons_heavy_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 = warriors_sons_heavy_infantry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = warriors_sons_heavy_infantry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = warriors_sons_heavy_infantry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = warriors_sons_heavy_infantry
            }
        }
    }
}

### Warriors Sons Heavy Cav Spawner
DI_warriors_sons_heavy_cav_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 = warriors_sons_heavy_cav
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = warriors_sons_heavy_cav
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = warriors_sons_heavy_cav
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = warriors_sons_heavy_cav
            }
        }
    }
}

### Holy Guard Spawner
DI_holy_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 = holy_guard
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = holy_guard
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = holy_guard
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = holy_guard
            }
        }
    }
}

### Fiery Hand Spawner
DI_fiery_hand_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 = fiery_hand
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = fiery_hand
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = fiery_hand
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = fiery_hand
            }
        }
    }
}

### Dothraki Screamers Spawner
DI_dothraki_screamers_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 = dothraki_screamers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = dothraki_screamers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = dothraki_screamers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = dothraki_screamers
            }
        }
    }
}

### Northern Spears Spawner
DI_northern_spears_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 = northern_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = northern_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = northern_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = northern_spears
            }
        }
    }
}

### Dornish Crossbows Spawner
DI_dornish_crossbows_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 = dornish_crossbows
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = dornish_crossbows
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = dornish_crossbows
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = dornish_crossbows
            }
        }
    }
}

### Vale Heavy Infantry Spawner
DI_vale_heavy_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 = vale_heavy_infantry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = vale_heavy_infantry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = vale_heavy_infantry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = vale_heavy_infantry
            }
        }
    }
}

### Crownlands Spears Spawner
DI_crownlands_spears_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 = crownlands_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = crownlands_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = crownlands_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = crownlands_spears
            }
        }
    }
}

### Reach Light Cavalry Spawner
DI_reach_light_cavalry_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 = reach_light_cavalry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = reach_light_cavalry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = reach_light_cavalry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = reach_light_cavalry
            }
        }
    }
}

### Riverlands Light Infantry Spawner
DI_riverlands_light_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 = riverlands_light_infantry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = riverlands_light_infantry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = riverlands_light_infantry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = riverlands_light_infantry
            }
        }
    }
}

### Westerlands Knights Spawner
DI_westerlands_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 = westerlands_knights
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = westerlands_knights
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = westerlands_knights
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = westerlands_knights
            }
        }
    }
}

### Stormlands Heavy Infantry Spawner
DI_stormlands_heavy_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 = stormlands_heavy_infantry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = stormlands_heavy_infantry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = stormlands_heavy_infantry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = stormlands_heavy_infantry
            }
        }
    }
}

### Stepstone Sailors Spawner
DI_stepstone_sailors_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 = stepstone_sailors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = stepstone_sailors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = stepstone_sailors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = stepstone_sailors
            }
        }
    }
}

### Westerosi Sellswords Spawner
DI_westerosi_sellswords_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 = westerosi_sellswords
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = westerosi_sellswords
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = westerosi_sellswords
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = westerosi_sellswords
            }
        }
    }
}

### Giant Regiment Spawner
DI_giant_regiment_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 = giant_regiment
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = giant_regiment
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = giant_regiment
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = giant_regiment
            }
        }
    }
}

### Goldenheart Bowmen Spawner
DI_goldenheart_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 = goldenheart_bowmen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = goldenheart_bowmen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = goldenheart_bowmen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = goldenheart_bowmen
            }
        }
    }
}

### Ruby Spearwomen Spawner
DI_ruby_spearwomen_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 = ruby_spearwomen
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = ruby_spearwomen
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = ruby_spearwomen
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = ruby_spearwomen
            }
        }
    }
}

### Battering Ram Spawner
DI_battering_ram_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 = battering_ram
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = battering_ram
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = battering_ram
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = battering_ram
            }
        }
    }
}

### Sarsfield Horse Archers Spawner
DI_sarsfield_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 = sarsfield_horse_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sarsfield_horse_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sarsfield_horse_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sarsfield_horse_archers
            }
        }
    }
}

### Nw Rangers Spawner
DI_nw_rangers_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 = nw_rangers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = nw_rangers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = nw_rangers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = nw_rangers
            }
        }
    }
}

### Nw Trackers Spawner
DI_nw_trackers_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 = nw_trackers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = nw_trackers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = nw_trackers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = nw_trackers
            }
        }
    }
}

### Sworn Brothers Spawner
DI_sworn_brothers_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 = sworn_brothers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sworn_brothers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sworn_brothers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sworn_brothers
            }
        }
    }
}

### Shadow Spears Spawner
DI_shadow_spears_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 = shadow_spears
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = shadow_spears
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = shadow_spears
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = shadow_spears
            }
        }
    }
}

### Eastwatch Sailors Spawner
DI_eastwatch_sailors_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 = eastwatch_sailors
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = eastwatch_sailors
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = eastwatch_sailors
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = eastwatch_sailors
            }
        }
    }
}

### Laamp Settler Maa Spawner
DI_laamp_settler_maa_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 = laamp_settler_maa
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = laamp_settler_maa
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = laamp_settler_maa
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = laamp_settler_maa
            }
        }
    }
}

### Goldcloaks Spawner
DI_goldcloaks_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 = goldcloaks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = goldcloaks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = goldcloaks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = goldcloaks
            }
        }
    }
}

### Sea Watch Spawner
DI_sea_watch_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 = sea_watch
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = sea_watch
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = sea_watch
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = sea_watch
            }
        }
    }
}

### Redcloaks Spawner
DI_redcloaks_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 = redcloaks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = redcloaks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = redcloaks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = redcloaks
            }
        }
    }
}

### Greycloaks Spawner
DI_greycloaks_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 = greycloaks
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = greycloaks
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = greycloaks
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = greycloaks
            }
        }
    }
}

### Cailin Archers Spawner
DI_cailin_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 = cailin_archers
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = cailin_archers
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = cailin_archers
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = cailin_archers
            }
        }
    }
}

### Wildling Cavalry Spawner
DI_wildling_cavalry_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 = wildling_cavalry
                        men = scope:DI_story.var:DI_army_spawner_increment_value
                    }
                    location = scope:target.location
                    inheritable = no
                    name = wildling_cavalry
                }
            }
        }
        else = {
            spawn_army = {
                men_at_arms = {
                    type = wildling_cavalry
                    men = scope:DI_story.var:DI_army_spawner_increment_value
                }
                location = root.location
                inheritable = no
                name = wildling_cavalry
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}

### 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
            }
        }
    }
}
