OSP Kit Campaign New kingdom management(Module system download post #3)

Users who are viewing this thread

Berserker Pride

Grandmaster Knight
Module_Constants [Search for kingdom_heroes_begin]
kingdom_heroes_begin = "trp_npc1"
kingdom_heroes_end = kingdom_ladies_begin
####I'm not sure where those values usually start but change kingdom_heroes_begin to = "trp_npc1"
####If you add any new companions to your module they must go just after the previous companions.
####Edit: I forgot one important piece. You need to add a new slot for faction color in your module_constants.py. I add it below the "slot_faction_leader"
slot_faction_color = 12
Module_Dialogues
  [anyone,"view_member_char_requested", [], "All right, let me tell you...", "do_member_view_char",[(change_screen_view_character)]],####This is not ###new I simply put the dialogue after this line.

# Talk to any of your members with over 15 charisma.
  #Kingdom Management
  [anyone|plyr, "member_talk", [
        # (eq, "$talk_array_no", -1),
      (store_attribute_level,":companion_charisma","$g_talk_troop",3),
      (ge,":companion_charisma",15),
      (assign,":num_centers",0),
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
        (eq,":lord","trp_player"),
        (val_add,":num_centers",1),
      (try_end),
      (ge,":num_centers",1)],
     
      "I have decided to promote you.  You have shown enough leadership to be capable of managing your own Warband.",
      "assign_fief_1",[
      (troop_set_slot,"$g_talk_troop",slot_troop_change_to_faction,"fac_player_supporters_faction"),
      (troop_set_slot,"$g_talk_troop",slot_troop_occupation, slto_kingdom_hero),
      (troop_set_slot, "$g_talk_troop", slot_troop_wealth, 4000),###The higher you set this number the more troops will be in your companions army
      (try_begin),
          (store_skill_level,":companion_leadership",skl_leadership,"$g_talk_troop"),
          (ge,":companion_leadership",:cool:,
          (troop_set_slot, "$g_talk_troop", slot_troop_renown, 500),###
          (troop_set_slot, "$g_talk_troop", slot_troop_wealth, 6000),###Really big army if your companion has a lot of leadership
      (try_end),
      (try_begin),
          (troop_set_slot, "$g_talk_troop", slot_troop_original_faction,"fac_kingdom_6"),###I preset the player faction with unique troops
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_kingdom_6"),
      (try_end),
      (party_remove_members,"p_main_party","$g_talk_troop",1),
      (call_script, "script_change_player_relation_with_troop", "$g_talk_troop", 40),
      (troop_get_slot, ":player_banner", "trp_player", slot_troop_banner_scene_prop),#This assigns player kingdom lords your banner
      (troop_set_slot, "$g_talk_troop", slot_troop_banner_scene_prop,":player_banner"),     
      ]],

  [anyone|plyr, "assign_fief_1", [
        (assign,":num_centers",0),###All of this ensure that the player is lord of a castle he can give away.
      (try_for_range, ":center_no", castles_begin, castles_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
        (eq,":lord","trp_player"),
        (val_add,":num_centers",1),
      (try_end),
      (ge,":num_centers",1)],
     
    "You are to become a vassal lord.",
    "assign_fief_2",[]],

    [anyone|plyr, "assign_fief_1", [
      (assign,":num_centers",0),
      (try_for_range, ":center_no", towns_begin, towns_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
        (eq,":lord","trp_player"),
        (val_add,":num_centers",1),
      (try_end),
      (ge,":num_centers",1)],

    "You might even become lord of a town if you can be trusted.",
    "assign_fief_2",[]],
  [anyone, "assign_fief_2", [],"I will not fail you {playername}.  Should you need assistance on the battlefield call for me.","close_window",[
(jump_to_menu, "mnu_give_center_to_companion")]], 
  #Kingdom Management End
[anyone, "event_triggered",
  [
    (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "$g_talk_troop"),
    (neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),#Kingdom Management you don't want this coming up #for your kingdom   
(ge, "$g_center_taken_by_player_faction", 0),
    (str_store_party_name, s1, "$g_center_taken_by_player_faction"),
    ],
  "{s1} is not being managed by anyone. Whom shall I put in charge?", "center_captured_lord_advice",
  []],

#Installation: you can add these right after BPKM dialog in module_dialogs.py. However, if you want this option to be listed above the "*Leave*" option, then seerch #for the phrase "TODO: QUESTS COMMENT OUT END". Add these new dialogs above/below the 4th match.
#Dialog:
# (click to show/hide)
# Spd - New dialog option for BPKM
# Spd - add option to change kingdom setting
  [anyone|plyr,"lord_talk", [(eq, "$g_talk_troop_faction", "$players_kingdom"),  # Spd - Lord Kinlar tweak
                            #(eq, "$g_talk_troop_faction", "fac_player_supporters_faction"), # Spd - Original Native code
                            (neg|troop_slot_ge, "$g_talk_troop", slot_troop_prisoner_of_party, 0),
                      (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
                            ],
  "I want to make some change to our kingdom.", "change_kingdom_settings",[]],

  [anyone,"change_kingdom_settings", [],
  "Sure. What would you like to change?", "close_window",
      [
      (jump_to_menu, "mnu_change_kingdom_setting"),
      (leave_encounter),
      ]],

#KINGDOM MANAGEMENT #
  [anyone|plyr,"lord_give_order", [
      (assign,":num_centers",0),
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
        (eq,":lord","$g_talk_troop"),
        (val_add,":num_centers",1),
      (try_end),
      (ge,":num_centers",1)],
  "The kingdom is running low on resources.  I must disband your army and temporarily retake direct control of your territory",
  "remove_vassal_1",
  []],
  [anyone,"remove_vassal_1",[],"This would force me to disband all my troops to their homes are you sure you want to do that?",
  "remove_vassal_2",[]],
  [anyone|plyr,"remove_vassal_2",[],"Oh in that case never mind.",
  "lord_talk",[]],
  [anyone|plyr,"remove_vassal_2",[],"Unfortunately yes, disband your troops and rejoin my main party.",
  "lord_talk",[
      (try_for_range, ":center_no", castles_begin, castles_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
        (eq,":lord","$g_talk_troop"),
        (call_script, "script_give_center_to_lord", ":center_no", "trp_player", 0),
    (try_end),
    (troop_get_slot,":companion_army","$g_talk_troop",slot_troop_leaded_party),
    (remove_party,":companion_army"),
    (troop_set_slot,"$g_talk_troop",slot_troop_occupation, slto_player_companion),
    (party_force_add_members,"p_main_party","$g_talk_troop",1)]],
   
# Spd - add option to view lord stats#New script goes just below the script above.
# for BPKM 
  [anyone|plyr,"lord_talk", [
                            (eq, "$g_talk_troop_faction", "$players_kingdom"),  # Spd - Lord Kinlar tweak
                      #(eq, "$g_talk_troop_faction", "fac_player_supporters_faction"), # Spd - Original Native code
                            (faction_slot_eq, "fac_player_supporters_faction", slot_faction_marshall, "trp_player"),
                            (is_between, "$g_talk_troop", kingdom_heroes_begin, kingdom_heroes_end),
                      (neg|troop_slot_ge, "$g_talk_troop", slot_troop_prisoner_of_party, 0),
                            ],
  "I want to see your skills.", "companion_lord_view_stats",[]],

  [anyone,"companion_lord_view_stats", [],
  "Well, of course.", "lord_pretalk",
  [
    (change_screen_view_character),
    ]],
   
#KINGDOM MANAGEMENT END #
  [anyone|plyr,"lord_give_order", [],##The second kingdom management goes just above this line.  This Dialogue lets you disband a lord.  Eventually I ###want to #have it automatically go to the troop transfer screen first so you can fill your part with as many of your companions troops as possible.
###
Module_Scripts [Search for the Scripts in question then edit them]
###This one line goes just after the very beginning of the first script game_start put it just before this line.###
(faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),####
(faction_set_slot, "fac_kingdom_6", slot_faction_state, sfs_inactive),###Kingdom Management if you don't add this line your rebel kingdom will show up in the list.

("activate_deactivate_player_faction",###Replace this script with this new one.  or just sub in the lines between Kingdom Management or with ### #beside them
    [
      (store_script_param, ":last_interaction_with_faction", 1),
      (try_begin),
        (assign, ":has_center", 0),
        (try_for_range, ":cur_center", centers_begin, centers_end),
          (store_faction_of_party, ":cur_center_faction", ":cur_center"),
          (eq, ":cur_center_faction", "fac_player_supporters_faction"),
          (assign, ":has_center", 1),
        (try_end),
        (try_begin),
          (eq, ":has_center", 1),
          (neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_active),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
          (str_store_faction_name, s1, ":last_interaction_with_faction"),
          (faction_set_name, "fac_player_supporters_faction", "@Kingdom of {playername}"),######New name for the kingdom
          (faction_set_color, "fac_player_supporters_faction", 0xFFAAAAAA),###set your colour I will eventually make this a menu choice Kingdom #Management     
          (assign, "$players_kingdom", "fac_player_supporters_faction"),
          (assign, "$g_player_banner_granted", 1),
          (faction_set_slot,"fac_player_supporters_faction", slot_faction_marshall,"trp_player"),###Kingdom Management make the player marshall #automatically.
          (call_script, "script_store_average_center_value_per_faction"),
          (call_script, "script_update_all_notes"),
          (call_script, "script_add_notification_menu", "mnu_notification_player_faction_active", 0, 0),
        (else_try),
          (eq, ":has_center", 0),
          (faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
          (le, "$supported_pretender", 0),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
          (assign, "$players_kingdom", 0),
          (assign, "$players_oath_renounced_against_kingdom", 0),
          (assign, "$players_oath_renounced_given_center", 0),
          (assign, "$players_oath_renounced_begin_time", 0),
          (call_script, "script_store_average_center_value_per_faction"),
          (call_script, "script_update_all_notes"),
          (call_script, "script_add_notification_menu", "mnu_notification_player_faction_deactive", 0, 0),
        (try_end),
      (faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_culture_6"),#Kingdom Management Begin   
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop, "trp_rebel_swordsman"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_rebel_protector"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_rebel_light_cavalry"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_rebel_guardian"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_rebel_protector"),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_reinforcements_a, "pt_kingdom_6_reinforcements_a"),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_reinforcements_b, "pt_kingdom_6_reinforcements_b"),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_reinforcements_c, "pt_kingdom_6_reinforcements_c"),
      (try_end),
]),
######Kingdom Management End
("cf_get_random_active_faction_except_player_faction_and_faction",###Now when a faction is defeated the lords have a chance of joining you
    [
      (store_script_param_1, ":except_faction_no"),
      (assign, ":num_factions", 0),
      (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
        #(neq, ":faction_no", "fac_player_supporters_faction"),#Kingdom Management just tab this line out now they can join player faction
        (neq, ":faction_no", ":except_faction_no"),
        (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active),
        (val_add, ":num_factions", 1),
      (try_end),
      (gt, ":num_factions", 0),
      (assign, ":selected_faction", -1),
      (store_random_in_range, ":random_faction", 0, ":num_factions"),
      (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
        (ge, ":random_faction", 0),
        #(neq, ":faction_no", "fac_player_supporters_faction"),#Kingdom Management just tab this line out now they can join player faction
        (neq, ":faction_no", ":except_faction_no"),
        (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active),
        (val_sub, ":random_faction", 1),
        (lt, ":random_faction", 0),
        (assign, ":selected_faction", ":faction_no"),
      (try_end),
      (assign, reg0, ":selected_faction"),
  ]),

#script_village_recruit_volunteers_recruit#Kingdom Management search for this script. Replace the existing with this. #NOW EDITTED CHANGE IT!!!!!!!!!
  # INPUT: none
  # OUTPUT: none
  ("village_recruit_volunteers_recruit",#KKM RECRUIT special from whichever faction you are.
    [(store_faction_of_party, ":center_faction", "$current_town"),
    (try_begin),
    (eq,":center_faction","fac_player_supporters_faction"),
    (assign,":volunteer_troop","trp_rebel_recruit"),#had to directly assign what volunteer troop would be.  But it now works.
    #(faction_get_slot, ":volunteer_troop", "fac_player_supporters_faction", slot_faction_tier_1_troop),
    (else_try),
    (party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
    (try_end),   
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (store_skill_level, ":skill", "skl_persuasion", "trp_player"),#persuasion addition
    (val_add, ":volunteer_amount", ":skill"),#persuasion addition
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 10),#10 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),

#NEW SCRIPT PUT AT THE END OF module_scripts
# Spd - find next/previous center that belongs to player
# Originally design to find next/previous village ID, but can be used for other center type.
# Input: arg1 = starting center ID belongs to player
# Input: arg2 = ending center ID belongs to player
# Input: arg3 = propagation direction (1 = forward, 2 = backward)
# Output: reg40 = next/previous ID found
("cf_find_next_party_id",
    [
    (store_script_param, ":start_center", 1),
  (store_script_param, ":end_center", 2),
  (store_script_param, ":propagation", 3), 
  (store_add, ":start_center_plus_one", ":start_center", 1),
  (store_add, ":end_center_plus_one", ":end_center", 1), 
  (assign, ":counter", 0), 
  (try_begin),
      (eq, ":propagation", 1),
      (try_for_range, ":cur_center", ":start_center_plus_one", ":end_center_plus_one"),
        (party_slot_eq, ":cur_center", slot_town_lord, "trp_player"),
        (val_add, ":counter", 1),
        (try_begin),
            (eq, ":counter", 1),
            (assign, reg40, ":cur_center"),
        (try_end),       
      (try_end),
  (else_try),
      (eq, ":propagation", 2),
      (try_for_range_backwards, ":cur_center", ":start_center", ":end_center"),
        (party_slot_eq, ":cur_center", slot_town_lord, "trp_player"),
        (val_add, ":counter", 1),
        (try_begin),
            (eq, ":counter", 1),
            (assign, reg40, ":cur_center"),
        (try_end),       
      (try_end),
  (try_end),     
  ]),
#Module_Triggers New Triggers go at the bottom before the last ]
(24*7,0,0,[(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_inactive)],#Disable all lords if your faction is wiped out. Kingdom #Management 
    [(try_for_range, ":companion", "trp_npc1","trp_kingdom_heroes_including_player_begin"),
    (troop_slot_eq,":companion",slot_troop_occupation, slto_kingdom_hero),#Companion needs to be a lord     
    (troop_get_slot,":companion_army",":companion",slot_troop_leaded_party),
    (remove_party,":companion_army"),
    (troop_set_slot,":companion",slot_troop_occupation, slto_player_companion),
    (party_force_add_members,"p_main_party",":companion",1),
    (display_message,"@Your faction has been eliminated. Any surviving leaders have disbanded their troops and rejoined your party.",0xFFFFFFAA),     
    (try_end),
    ]),

(24*7,0,0,[(assign,":num_centers",0),#Disband Centreless lords every week.
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (val_add,":num_centers",1),
      (try_end),
      (assign,":num_lords",0),
      (try_for_range,":lord","trp_npc1","trp_kingdom_heroes_including_player_begin"),#Need to put all potential companions in a range.
        (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
        (val_add,":num_lords",1),
      (try_end),
      (lt,":num_centers",":num_lords"),
      (display_message,"@One of your centres has fallen. Within the week one of your commanders will be forced to disband their forces.")],

  [(try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
    (store_faction_of_party, ":center_faction", ":center_no"),
    (eq, ":center_faction", "fac_player_supporters_faction"), #Only centers owned by player faction
  (try_for_range, ":companion", "trp_npc1","trp_kingdom_heroes_including_player_begin"),
    (troop_slot_eq,":companion",slot_troop_occupation, slto_kingdom_hero),#Companion needs to be a lord
    (try_begin),
    (neg|party_slot_eq,":center_no",slot_town_lord,":companion"),#Make him rejoin if he don't have a castle/town from the player faction
    (troop_get_slot,":companion_army",":companion",slot_troop_leaded_party),
    (remove_party,":companion_army"),
    (troop_set_slot,":companion",slot_troop_occupation, slto_player_companion),
    (party_force_add_members,"p_main_party",":companion",1),
    (display_message,"@The loss of their base of operations has forced one of your armies to disband.",0xFFFFFFAA),
  (try_end),
  (try_end),
  (try_end),
  ]),
#Module_Simple_Triggers Edit the first trigger the next two are new.  Again make sure you add a comma to the previous trigger at the end of the file if their isn't one #currently.
# Asking the ownership of captured centers to the player
  (3,
  [(faction_get_slot, ":leader", "fac_player_supporters_faction", slot_faction_leader),#KINGDOM MANAGEMENT
    (neq,":leader","trp_player"),#KINGDOM MANAGEMENT if you don't add these two lines random useless claimant conversations start with yourself
    (assign, "$g_center_taken_by_player_faction", -1),
    (try_for_range, ":center_no", centers_begin, centers_end),
      (eq, "$g_center_taken_by_player_faction", -1),
      (store_faction_of_party, ":center_faction", ":center_no"),
      (eq, ":center_faction", "fac_player_supporters_faction"),
      (this_or_next|party_slot_eq, ":center_no", slot_town_lord, stl_reserved_for_player),
      (this_or_next|party_slot_eq, ":center_no", slot_town_lord, stl_unassigned),
      (party_slot_eq, ":center_no", slot_town_lord, stl_rejected_by_player),
      (assign, "$g_center_taken_by_player_faction", ":center_no"),
    (try_end),
    (ge, "$g_center_taken_by_player_faction", 0),
    (start_map_conversation, ":leader"),
    ]),

(24*90,[#Every three months a massive campaign begins.
  (try_for_range, ":kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end),##All this trigger does is make lords more likely to form armies
      (troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_kingdom_hero), ##It also makes yours more obedient.
      (troop_set_slot, ":kingdom_hero", slot_troop_readiness_to_join_army, 90),##I will eventually make a feast event that costs you money but
      (troop_set_slot, ":kingdom_hero", slot_troop_readiness_to_follow_orders, 100),##Does this for just your lords
  (try_end),
  (display_message,"@A time of war is upon you. The lords have mobilized their forces!",0xFFFFFFAA),
  ]),

  #Set flag trigger
(24,[##Updates your lords flags should you happen to change yours
(try_for_range, ":kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end),
          (store_troop_faction, ":kingdom_hero_faction", ":kingdom_hero"),
          (eq, ":kingdom_hero_faction", "fac_player_supporters_faction"),
          (troop_get_slot,":player_banner","trp_player",slot_troop_banner_scene_prop),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":player_banner"),
(try_end),
]),
#module_troops this is a sample troop tree for your new culture (culture_6
#Put these troops right after the last rhodok troop (rhodok_castle_guard)
["rebel_recruit","Recruit","Recruit",tf_guarantee_boots|tf_guarantee_armor,0, reserved,  fac_commoners,[
  itm_shirt,itm_steppe_armor,itm_robe,itm_nomad_boots,itm_leather_boots,itm_ankle_boots,itm_sword_medieval_a,
  itm_sword_khergit_1,itm_spear,itm_fighting_axe,itm_sumpter_horse],
  str_9|agi_6|int_4|cha_4|level(5),wp(70),knows_weapon_master_3|knows_power_strike_1|knows_athletics_2|knows_riding_1|
  knows_tactics_1,
  mercenary_face_1, mercenary_face_2],
  #######2
  ["rebel_footman","Greenhorn","Greenhorns",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_helmet,0,0,fac_outlaws,
  [itm_one_handed_war_axe_a,itm_one_handed_battle_axe_b,itm_tab_shield_round_a,
    itm_studded_leather_coat,itm_ragged_outfit,itm_leather_boots],
  def_attrib|level(7),wp(90),knows_ironflesh_2|knows_power_strike_2|knows_power_throw_2|knows_riding_2|knows_athletics_4,nord_face_young_1, nord_face_old_2],
  ["rebel_militia","Militia","Militia",tf_guarantee_ranged|tf_guarantee_boots|tf_guarantee_armor,0,0,fac_neutral,
  [itm_bolts,itm_light_crossbow,itm_hunting_crossbow,itm_axe,itm_sword_medieval_a,
    itm_shirt,itm_leather_armor,itm_hide_boots,itm_ankle_boots,itm_kettle_hat],
  def_attrib|level(19),wp_melee(80)|wp_crossbow(100),knows_common|knows_ironflesh_3,swadian_face_young_1, swadian_face_old_2],
  ########3
  ["rebel_swordsman","Swordsman","Swordsmen",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield,0,0,fac_neutral,
  [itm_bastard_sword_a,itm_sword_medieval_c,itm_sword_medieval_a,itm_tab_shield_heater_b,
    itm_red_gambeson,itm_blue_gambeson,itm_ankle_boots,itm_footman_helmet],
  def_attrib|level(14),wp_melee(100),knows_common|knows_ironflesh_2|knows_power_strike_4|knows_athletics_5,swadian_face_young_1, swadian_face_old_2], 
  ["rebel_light_cavalry","Light Cavalry","Light Cavalry",tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_ranged|tf_guarantee_horse,0,0,fac_khergits,
  [itm_javelin,itm_javelin,itm_sword_khergit_1,itm_sword_khergit_2,
    itm_steppe_armor,itm_hide_boots,itm_steppe_horse],
  def_attrib|level(14),wp(80)|wp_throwing(200),knows_riding_3|knows_ironflesh_2|knows_power_strike_2|knows_horse_archery_4|knows_power_throw_6,khergit_face_young_1, khergit_face_older_2],
  ["rebel_crossbowman","Crossbowman","Crossbowmen",tf_guarantee_ranged|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield,0,0,fac_neutral,
  [itm_bolts,itm_crossbow,itm_fighting_pick,itm_sword_medieval_a,itm_tab_shield_heater_b,
    itm_gambeson,itm_hide_boots,itm_ankle_boots,itm_kettle_hat],
  def_attrib|level(19),wp_melee(100)|wp_crossbow(150),knows_common|knows_ironflesh_3,swadian_face_young_1, swadian_face_old_2],
  ["rebel_javelineer","Javelineer","Javelineers",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_ranged|tf_guarantee_shield,0,0,fac_khergits,
  [itm_jarid,itm_jarid,itm_jarid,itm_sword_khergit_1,itm_sword_khergit_4,
    itm_nomad_robe,itm_hide_boots],
  def_attrib|level(14),wp(100)|wp_throwing(200),knows_riding_3|knows_ironflesh_2|knows_power_throw_6,khergit_face_young_1, khergit_face_older_2],
  #######4
  ["rebel_protector","Protector","Protectors",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_helmet,0,0,fac_outlaws,
  [itm_military_hammer,itm_tab_shield_pavise_d,itm_jarid,itm_javelin,
    itm_guard_helmet,itm_plate_armor,itm_iron_greaves,itm_gauntlets],
  def_attrib|level(2:cool:,wp(80),knows_ironflesh_3|knows_power_strike_3|knows_power_throw_5|knows_athletics_2,nord_face_middle_1, nord_face_older_2], 
  ["rebel_spearman","Quick Spearman","Quick Spearmen",tf_guarantee_shield|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet,0,0,fac_neutral,
  [itm_pike,itm_tab_shield_heater_c,
    itm_surcoat_over_mail,itm_hide_boots,itm_ankle_boots,itm_helmet_with_neckguard],
  def_attrib|level(20),wp_melee(150),knows_common|knows_riding_3|knows_ironflesh_4|knows_power_strike_3|knows_athletics_4,swadian_face_middle_1, swadian_face_old_2],
  ["rebel_cavalry","War Hobilar","War Hobilars",tf_guarantee_shield|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet|tf_guarantee_horse,0,0,fac_neutral,
  [itm_battle_axe,itm_sword_viking_2,itm_sword_khergit_4,itm_tab_shield_kite_c,
    itm_mail_hauberk,itm_nomad_boots,itm_spiked_helmet,itm_hunter],
  def_attrib|level(19),wp_melee(130),knows_ironflesh_4|knows_power_strike_4|knows_riding_1,vaegir_face_young_1, vaegir_face_older_2], 
  ["rebel_raider","Raider","Raiders",tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_horse|tf_guarantee_shield,0,0,fac_khergits,
  [itm_sword_khergit_4,itm_lance,itm_lance,itm_jarid,
    itm_khergit_cavalry_helmet,itm_khergit_guard_boots,itm_leather_gloves,itm_steppe_horse],
  def_attrib|level(1:cool:,wp(140),knows_riding_6|knows_power_strike_4|knows_power_throw_4|knows_ironflesh_3|knows_horse_archery_3,khergit_face_middle_1, khergit_face_older_2],
  ["rebel_armbruster","Armbruster","Armbrusters",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_ranged|tf_guarantee_helmet,0, reserved,  fac_commoners,[itm_studded_leather_coat,
  itm_mail_chausses,itm_iron_staff,itm_military_pick,itm_steel_shield,itm_guard_helmet,itm_skullcap,itm_mail_coif,itm_heavy_crossbow,itm_steel_bolts],
  str_20|agi_20|int_20|cha_15|level(20),wp(100)|wp_crossbow(130),knows_weapon_master_3|knows_power_strike_3|knows_athletics_4|knows_riding_1|
  knows_tactics_1|knows_ironflesh_3,
  mercenary_face_1,mercenary_face_2], 
  ["rebel_archer","Veteran Archer","Veteran Archers",tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_ranged,0,0,fac_khergits,
  [itm_arrows,itm_sword_medieval_c,itm_strong_bow,itm_tab_shield_round_b,
    itm_footman_helmet,itm_footman_helmet,itm_khergit_guard_armor,itm_mail_chausses],
  def_attrib|level(15),wp(110)|wp_archery(150)|wp_throwing(80),knows_power_draw_3|knows_power_strike_4,khergit_face_younger_1, khergit_face_old_2],
  ["rebel_initiate","Clan Initiate","Clan Initiates",tf_mounted|tf_guarantee_armor,0,0,fac_khergits,
  [itm_jarid,itm_rabati,itm_nomad_robe],
  str_20|agi_30|int_30|cha_10|level(14),wp(150)|wp_throwing(200),knows_power_throw_5|knows_athletics_7|knows_power_strike_5,khergit_face_younger_1, khergit_face_old_2],
  #######5
  ["rebel_guardian","Guardian","Guardians",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_helmet,0,0,fac_outlaws,
  [itm_polehammer,itm_jarid,itm_jarid,
    itm_great_helmet,itm_plate_armor,itm_iron_greaves,itm_gauntlets],
  def_attrib|level(25),wp(70),knows_ironflesh_10|knows_power_strike_8|knows_power_throw_5,nord_face_middle_1, nord_face_older_2],
  ["rebel_lancer","Heavy Lancer","Heavy Lancers",tf_guarantee_shield|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet,0,0,fac_neutral,
  [itm_pike,itm_poleaxe,itm_tab_shield_kite_d,
    itm_surcoat_over_mail,itm_hide_boots,itm_ankle_boots,itm_kettle_hat],
  def_attrib|level(23),wp_melee(200),knows_common|knows_riding_3|knows_ironflesh_10|knows_power_strike_5|knows_athletics_4,swadian_face_middle_1, swadian_face_old_2],
  ["rebel_knight","Assault Knight","Assault Knights",tf_mounted|tf_guarantee_shield|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet|tf_guarantee_horse,0,0,fac_neutral,
  [itm_great_axe,itm_heavy_lance,itm_great_bardiche,
    itm_banded_armor,itm_mail_chausses,itm_spiked_helmet,itm_warhorse,itm_charger],
  def_attrib|level(23),wp_melee(140),knows_athletics_2|knows_ironflesh_4|knows_power_strike_4|knows_riding_7,vaegir_face_young_1, vaegir_face_older_2],
  ["rebel_handgonnemann","Mounted Crossbowman","Mounted Crossbowman",tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_ranged|tf_guarantee_helmet|tf_guarantee_horse|tf_mounted,0, reserved,  fac_commoners,[  itm_surcoat_over_mail,itm_mail_chausses,itm_battle_axe,itm_bastard_sword_b,itm_steel_shield,itm_guard_helmet,itm_skullcap,itm_mail_coif,itm_light_crossbow,
itm_steel_bolts,itm_warhorse],
  def_attrib|level(23),wp(80)|wp_crossbow(300),knows_weapon_master_3|knows_power_strike_5|knows_athletics_4|knows_riding_1|
  knows_tactics_1|knows_ironflesh_5|knows_horse_archery_6,
  mercenary_face_1,mercenary_face_2], 
  ["rebel_sniper","Ambusher","Ambushers",tf_mounted|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_shield|tf_guarantee_ranged,0,0,fac_khergits,
  [itm_arrows,itm_scimitar,itm_war_bow,itm_tab_shield_round_d,
    itm_spiked_helmet,itm_studded_leather_coat,itm_tribal_warrior_outfit,itm_mail_chausses],
  def_attrib|level(21),wp(110)|wp_archery(170)|wp_throwing(80),knows_power_draw_5|knows_power_strike_5,khergit_face_younger_1, khergit_face_old_2],
  ["rebel_clansman","Khergit Assassin","Khergit Assassins",tf_guarantee_shield|tf_guarantee_helmet,0, reserved,  fac_commoners,[
  itm_war_bow,itm_khergit_arrows,itm_jarid,itm_throwing_axes,itm_glaive,itm_tab_shield_round_e,itm_sword_khergit_4,itm_khergit_guard_helmet],
  str_30|agi_30|int_20|cha_15|level(25),wp(300)|wp_throwing(300),knows_weapon_master_3|knows_power_strike_10|knows_athletics_10|knows_riding_1|
  knows_tactics_1|knows_ironflesh_10|knows_power_throw_10|knows_surgery_10|knows_power_draw_8,
  khergit_face_young_1,khergit_face_young_2],

###Put these upgrade lines at the bottom of the file after the others upgrade lines
upgrade2(troops,"rebel_recruit","rebel_footman","rebel_militia")
upgrade2(troops,"rebel_footman","rebel_light_cavalry","rebel_swordsman")
upgrade2(troops,"rebel_militia","rebel_javelineer","rebel_crossbowman")
upgrade2(troops,"rebel_swordsman","rebel_protector","rebel_spearman")
upgrade2(troops,"rebel_crossbowman","rebel_armbruster","rebel_archer")
upgrade(troops,"rebel_javelineer","rebel_initiate")
upgrade2(troops,"rebel_light_cavalry","rebel_cavalry","rebel_raider")
upgrade(troops,"rebel_protector","rebel_guardian")
upgrade(troops,"rebel_spearman","rebel_lancer")
upgrade(troops,"rebel_armbruster","rebel_handgonnemann")
upgrade(troops,"rebel_archer","rebel_sniper")
upgrade(troops,"rebel_cavalry","rebel_knight")
upgrade(troops,"rebel_initiate","rebel_clansman") 
module_factions
("culture_6",  "culture_6", 0, 0.9, [], []),#put after culture_5

("kingdom_6",  "Rebel Kingdom", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xFFFFFFFF),###put after kingdom_5
module_party_templates
###put this after kingdom_5_reinforcements
("kingdom_6_reinforcements_a", "kingdom_6_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_rebel_light_cavalry,4,7),(trp_rebel_militia,4,7),(trp_rebel_swordsman,4,7),(trp_rebel_crossbowman,4,7),(trp_rebel_javelineer,4,7)]),
  ("kingdom_6_reinforcements_b", "kingdom_6_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_rebel_initiate,4,7),(trp_rebel_protector,3,7),(trp_rebel_cavalry,4,7),(trp_rebel_armbruster,4,7),(trp_rebel_archer,4,7),(trp_rebel_raider,4,7)]),
  ("kingdom_6_reinforcements_c", "kingdom_6_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_rebel_guardian,4,5),(trp_rebel_lancer,4,5),(trp_rebel_knight,4,5),(trp_rebel_handgonnemann,4,5),(trp_rebel_clansman,4,7)]),
module_game_menus two posts below due to character limit.
Credit must go to SPD_Phoenix, Ruthven, Cruger for assistance
and Highlander and Wicketshot for making their code open source so I could edit it.
The module system download is two posts below as well.
 
Without having checked anything about it, I just have a thought:

The reason why that the simple trigger that respawn parties isn't working is obviously because that it only respawn troops that are between kingdom_heroes_begin and kingdom_heroes_end .. It might work if you change the kingdom_heroes_begin to "trp_npc1" instead of "trp_kingdom_1_lord" .. Besides the simple triggers that refresh AI etc also only refresh troops between kingdom_heroes_begin and kingdom_heroes_end,  so putting the the npcs in this will also prevent complete inactivity from their side..

Just an idea, hope you can make it working..
 
module_game_menus here due to post length.
#KINGDOM MANAGEMENT BEGIN
# Spd - Select center to give to companion. Must be a town/castle when promoting and can't back out. Can be anything and can back out if it is an addition.
  ("give_center_to_companion",0,
  "You are to become lord of a...",
  "none",
  [
  (assign, ":num_town", 0),
  (assign, ":num_castle", 0),
  (assign, reg22, 0),
  (try_for_range, ":cur_center", walled_centers_begin, walled_centers_end),
      (party_slot_eq, ":cur_center", slot_town_lord, "trp_player"),
      (try_begin),
        (party_slot_eq, ":cur_center", slot_party_type, spt_town),
        (val_add, ":num_town", 1),
      (else_try),
        (party_slot_eq, ":cur_center", slot_party_type, spt_castle),
        (val_add, ":num_castle", 1),
      (try_end),
  (try_end),
# Check if troop has any center.
  (try_for_range, ":cur_center", centers_begin, centers_end),
      (party_slot_eq, ":cur_center", slot_town_lord, "$g_talk_troop"),
      (val_add, reg22, 1),
  (try_end),
 
  (assign, reg20, ":num_town"),
  (assign, reg21, ":num_castle"),
  ],
    [
      ("give_town",
    [
    (this_or_next|gt, reg20, 1),
    (eq, reg22, 0),
    ], "Town.",
      [
        (jump_to_menu, "mnu_give_town_to_companion"),
      ]),
   
    ("give_castle",
    [
    (this_or_next|ge, reg21, 1),
    (eq, reg22, 0),
    ], "Castle.",
      [
        (jump_to_menu, "mnu_give_castle_to_companion"),
      ]),
          ("give_castle",
    [
    (gt, reg22, 0),
    ], "Village.",
      [
        (jump_to_menu, "mnu_give_village_to_companion"),
      ]),
    ("go_back",[(gt, reg22, 0),], "No. Forget it.",
      [
      (change_screen_return),
      ]),
  ]
  ),

# Spd - Select Town to give to companion
# For BPKM
  ("give_town_to_companion",0,
  "Select a town",
  "none",
  [],
    [
      ("town_1",[(party_slot_eq, "p_town_1", slot_town_lord, "trp_player")], "Sargoth.",
      [
      (call_script, "script_give_center_to_lord", "p_town_1", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("town_2",[(party_slot_eq, "p_town_2", slot_town_lord, "trp_player")], "Tihr.",
      [
      (call_script, "script_give_center_to_lord", "p_town_2", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("town_3",[(party_slot_eq, "p_town_3", slot_town_lord, "trp_player")], "Veluca.",
      [
      (call_script, "script_give_center_to_lord", "p_town_3", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("town_4",[(party_slot_eq, "p_town_4", slot_town_lord, "trp_player")], "Suno.",
      [
      (call_script, "script_give_center_to_lord", "p_town_4", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("town_5",[(party_slot_eq, "p_town_5", slot_town_lord, "trp_player")], "Jelkala.",
      [
      (call_script, "script_give_center_to_lord", "p_town_5", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_6",[(party_slot_eq, "p_town_6", slot_town_lord, "trp_player")], "Praven.",
      [
      (call_script, "script_give_center_to_lord", "p_town_6", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("town_7",[(party_slot_eq, "p_town_7", slot_town_lord, "trp_player")], "Uxkhal.",
      [
      (call_script, "script_give_center_to_lord", "p_town_7", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_8",[(party_slot_eq, "p_town_8", slot_town_lord, "trp_player")], "Reyvadin.",
      [
      (call_script, "script_give_center_to_lord", "p_town_8", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_9",[(party_slot_eq, "p_town_9", slot_town_lord, "trp_player")], "Khudan.",
      [
      (call_script, "script_give_center_to_lord", "p_town_9", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_10",[(party_slot_eq, "p_town_10", slot_town_lord, "trp_player")], "Tulga.",
      [
      (call_script, "script_give_center_to_lord", "p_town_10", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_11",[(party_slot_eq, "p_town_11", slot_town_lord, "trp_player")], "Curaw.",
      [
      (call_script, "script_give_center_to_lord", "p_town_11", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_12",[(party_slot_eq, "p_town_12", slot_town_lord, "trp_player")], "Wercheg.",
      [
      (call_script, "script_give_center_to_lord", "p_town_12", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_13",[(party_slot_eq, "p_town_13", slot_town_lord, "trp_player")], "Rivacheg.",
      [
      (call_script, "script_give_center_to_lord", "p_town_13", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_14",[(party_slot_eq, "p_town_14", slot_town_lord, "trp_player")], "Halmar.",
      [
      (call_script, "script_give_center_to_lord", "p_town_14", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_15",[(party_slot_eq, "p_town_15", slot_town_lord, "trp_player")], "Yalen.",
      [
      (call_script, "script_give_center_to_lord", "p_town_15", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_16",[(party_slot_eq, "p_town_16", slot_town_lord, "trp_player")], "Dhirim.",
      [
      (call_script, "script_give_center_to_lord", "p_town_16", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_17",[(party_slot_eq, "p_town_17", slot_town_lord, "trp_player")], "Ichamur.",
      [
      (call_script, "script_give_center_to_lord", "p_town_17", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("town_18",[(party_slot_eq, "p_town_18", slot_town_lord, "trp_player")], "Narra.",
      [
      (call_script, "script_give_center_to_lord", "p_town_18", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("go_back",[], "No, a town is too valuable right now. I shall give you...",
      [
        (jump_to_menu, "mnu_give_center_to_companion"),
        ]),
    ]
  ),

# Spd - Select Castle to give to companion
# For BPKM
  ("give_castle_to_companion",0,
  "Select a castle",
  "none",
  [
    #(assign, "$g_talk_troop", reg30),
    ],
    [
      ("castle_1",[(party_slot_eq, "p_castle_1", slot_town_lord, "trp_player")], "Culmarr Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_1", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("castle_2",[(party_slot_eq, "p_castle_2", slot_town_lord, "trp_player")], "Malayurg Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_2", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("castle_3",[(party_slot_eq, "p_castle_3", slot_town_lord, "trp_player")], "Bulugha Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_3", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("castle_4",[(party_slot_eq, "p_castle_4", slot_town_lord, "trp_player")], "Radoghir Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_4", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("castle_5",[(party_slot_eq, "p_castle_5", slot_town_lord, "trp_player")], "Tehlrog Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_5", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_6",[(party_slot_eq, "p_castle_6", slot_town_lord, "trp_player")], "Tilbaut Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_6", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
      ("castle_7",[(party_slot_eq, "p_castle_7", slot_town_lord, "trp_player")], "Sungetche Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_7", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_8",[(party_slot_eq, "p_castle_8", slot_town_lord, "trp_player")], "Jeirbe Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_8", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_9",[(party_slot_eq, "p_castle_9", slot_town_lord, "trp_player")], "Jamiche Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_9", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_10",[(party_slot_eq, "p_castle_10", slot_town_lord, "trp_player")], "Alburq Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_10", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_11",[(party_slot_eq, "p_castle_11", slot_town_lord, "trp_player")], "Curin Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_11", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_12",[(party_slot_eq, "p_castle_12", slot_town_lord, "trp_player")], "Chalbek Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_12", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_13",[(party_slot_eq, "p_castle_13", slot_town_lord, "trp_player")], "Kelredan Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_13", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_14",[(party_slot_eq, "p_castle_14", slot_town_lord, "trp_player")], "Maras Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_14", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_15",[(party_slot_eq, "p_castle_15", slot_town_lord, "trp_player")], "Ergellon Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_15", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_16",[(party_slot_eq, "p_castle_16", slot_town_lord, "trp_player")], "Almerra Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_16", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_17",[(party_slot_eq, "p_castle_17", slot_town_lord, "trp_player")], "Distar Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_17", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_18",[(party_slot_eq, "p_castle_18", slot_town_lord, "trp_player")], "Ismirala Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_18", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_19",[(party_slot_eq, "p_castle_19", slot_town_lord, "trp_player")], "Yruma Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_19", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_20",[(party_slot_eq, "p_castle_20", slot_town_lord, "trp_player")], "Derchios Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_20", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_21",[(party_slot_eq, "p_castle_21", slot_town_lord, "trp_player")], "Ibdeles Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_21", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_22",[(party_slot_eq, "p_castle_22", slot_town_lord, "trp_player")], "Unuzdaq Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_22", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_23",[(party_slot_eq, "p_castle_23", slot_town_lord, "trp_player")], "Tevarin Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_23", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_24",[(party_slot_eq, "p_castle_24", slot_town_lord, "trp_player")], "Reindi Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_24", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_25",[(party_slot_eq, "p_castle_25", slot_town_lord, "trp_player")], "Ryibelet Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_25", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_26",[(party_slot_eq, "p_castle_26", slot_town_lord, "trp_player")], "Senuzgda Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_26", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_27",[(party_slot_eq, "p_castle_27", slot_town_lord, "trp_player")], "Rindyar Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_27", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_28",[(party_slot_eq, "p_castle_28", slot_town_lord, "trp_player")], "Grunwalder Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_28", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_29",[(party_slot_eq, "p_castle_29", slot_town_lord, "trp_player")], "Nelag Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_29", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_30",[(party_slot_eq, "p_castle_30", slot_town_lord, "trp_player")], "Asugan Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_30", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_31",[(party_slot_eq, "p_castle_31", slot_town_lord, "trp_player")], "Vyincourd Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_31", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_32",[(party_slot_eq, "p_castle_32", slot_town_lord, "trp_player")], "Knudarr Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_32", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_33",[(party_slot_eq, "p_castle_33", slot_town_lord, "trp_player")], "Etrosq Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_33", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_34",[(party_slot_eq, "p_castle_34", slot_town_lord, "trp_player")], "Hrus Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_34", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_35",[(party_slot_eq, "p_castle_35", slot_town_lord, "trp_player")], "Haringoth Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_35", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_36",[(party_slot_eq, "p_castle_36", slot_town_lord, "trp_player")], "Jelbegi Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_36", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_37",[(party_slot_eq, "p_castle_37", slot_town_lord, "trp_player")], "Dramug Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_37", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_38",[(party_slot_eq, "p_castle_38", slot_town_lord, "trp_player")], "Tulbuk Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_38", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_39",[(party_slot_eq, "p_castle_39", slot_town_lord, "trp_player")], "Slezkh Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_39", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("castle_40",[(party_slot_eq, "p_castle_40", slot_town_lord, "trp_player")], "Uhhun Castle.",
      [
      (call_script, "script_give_center_to_lord", "p_castle_40", "$g_talk_troop", 0),
        (change_screen_return),
        ]),
    ("go_back",[], "On second thought, I shall give you...",
      [
        (jump_to_menu, "mnu_give_center_to_companion"),
        ]),
    ]
  ),

# Spd - Select village to give to companion
  ("give_village_to_companion",0,
  "I reward a village to you as an additional fief",
  "none",
  [
  (str_store_party_name, s40, reg40),
  ],
    [
      ("give_village",
      [
      (ge, reg41, 1),
      ], "{s40}",
      [
        (call_script, "script_give_center_to_lord", reg40, "$g_talk_troop", 0),     
      (change_screen_return),
      ]),
   
      ("next",
      [
      (lt, reg40, reg39),
      ], "Next village.",
      [
      (call_script, "script_cf_find_next_party_id", reg40, reg39, 1),
      (jump_to_menu, "mnu_give_village_to_companion"),
      ]),
     
      ("back",
      [
      (gt, reg40, reg3:cool:,
      ], "Previous village.",
      [
        (call_script, "script_cf_find_next_party_id", reg38, reg40, 2),
      (jump_to_menu, "mnu_give_village_to_companion"),
      ]),
     
      ("go_back",[(gt, reg22, 0),], "No. I should give you a better reward.",
      [
      (jump_to_menu, "mnu_give_center_to_companion"),
      ]),

  ]
  ),

# Spd - Menu Change kingdom setting
# For BPKM
  (
    "change_kingdom_setting",0,
    "What would you like to change",
    "none",
    [],
    [
      ("change_color",[],
          "Change faction color.",[(jump_to_menu,"mnu_select_faction_color")]),
       
      ("change_name",[],
          "Change faction name.",[
              (str_store_troop_name, s1, "trp_player"),
              (faction_set_name, "fac_player_supporters_faction", "@{s1}"),
          (change_screen_map),
              ]),
         
      ("return",[],"I don't want to change anything now.",[(leave_encounter),(change_screen_map),]),
    ]
  ),

# Spd - Menu change kingdom color 1
# For BPKM
    (
    "select_faction_color",0,
    "Which color would you like?",
    "none",
    [],
    [
      ("change_color_1",[],
        "Dark Cherry Red.",[
        (faction_set_color, "fac_player_supporters_faction", 0xFF330000), # Dark cherry red
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFF330000),
        (change_screen_return),
        ]),
       
      ("change_color_2",[],
        "Ultra marine blue.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFF120A8F), # Ultra marine blue
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFF120A8F),
        (change_screen_return),
            ]),
         
      ("change_color_3",[],
        "Celtics green.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFF00611C), # Celtics green
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFF00611C),
        (change_screen_return),
            ]),
   
    ("change_color_4",[],
        "Indigo purple.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFF4B0082), # Indigo purple
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFF4B0082),
        (change_screen_return),
            ]),
   
    ("change_color_5",[],
        "Crimson red.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFFDC143C), # Crimson red
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFFDC143C),
        (change_screen_return),
            ]),
   
    ("change_color_6",[],
        "Sand.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFFFFCC99), # Sand
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFFFFCC99),
        (change_screen_return),
            ]),
   
    ("change_color_7",[],
        "Dark olive green.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFFCAFF70), # Dark olive green
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFFCAFF70),
        (change_screen_return),
            ]),
   
    ("change_color_8",[],
        "Salmon.",[
            (faction_set_color, "fac_player_supporters_faction", 0xFFFA8072), # Salmon
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, 0xFFFA8072),
        (change_screen_return),
            ]),
   
    ("customize_color",[],
        "Let me customize my color.",[
        (jump_to_menu, "mnu_custom_settlement_color_menu"),
            ]),
   
    ("return",[],"I don't want to make any more changes for now.",[(leave_encounter),(change_screen_return),]),
    ]
  ),

# Menu customize kingdom color (this code is borred from Custom Settlement Mod)
# Borrowed from Custom Settlement Source Code  #
  #pick color
  ("custom_settlement_color_menu",0,
  "Pick a colour:",
  "none",
  [
  ],
  [
      ("custom_settlement_color_option_ri",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (le, ":fac_color", 0xee0000),
      ],"Increase Red",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_add, ":fac_color", 0x110000),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("custom_settlement_color_option_rd",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (ge, ":fac_color", 0x110000),
      ],"Decrease Red",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_sub, ":fac_color", 0x110000),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("custom_settlement_color_option_gi",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (store_div, ":div_color", ":fac_color", 0x010000),
        (val_mul, ":div_color", 0x010000),
        (val_sub, ":fac_color", ":div_color"),
        (le, ":fac_color", 0x00ee00),
      ],"Increase Green",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_add, ":fac_color", 0x001100),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("custom_settlement_color_option_gd",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (store_div, ":div_color", ":fac_color", 0x010000),
        (val_mul, ":div_color", 0x010000),
        (val_sub, ":fac_color", ":div_color"),
        (ge, ":fac_color", 0x001100),
      ],"Decrease Green",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_sub, ":fac_color", 0x001100),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("custom_settlement_color_option_bi",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (store_div, ":div_color", ":fac_color", 0x000100),
        (val_mul, ":div_color", 0x000100),
        (val_sub, ":fac_color", ":div_color"),
        (le, ":fac_color", 0x0000ee),
      ],"Increase Blue",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_add, ":fac_color", 0x000011),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("custom_settlement_color_option_bd",
      [
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),
        (store_div, ":div_color", ":fac_color", 0x000100),
        (val_mul, ":div_color", 0x000100),
        (val_sub, ":fac_color", ":div_color"),
        (ge, ":fac_color", 0x000011),
      ],"Decrease Blue",
      [ 
        (faction_get_slot, ":fac_color", "fac_player_supporters_faction", slot_faction_color),    #XX red, XX green, XX blue
        (val_sub, ":fac_color", 0x000011),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_color, ":fac_color"),    #XX red, XX green, XX blue
        (faction_set_color, "fac_player_supporters_faction", ":fac_color"),    #XX red, XX green, XX blue
        (display_message, "@(Current faction colour)", ":fac_color"),
        ]
      ),
      ("review_refresh_menu",[],"Refresh menu options.",
      [
      (jump_to_menu, "mnu_custom_settlement_color_menu"),
        ]
      ),
      ("settlement_action_grade_exit",[],"That will do for now.",
      [
      (change_screen_return),
        ]
      ), 
  ]
  ),
Here is a native module_system with all kingdom management code added.  Compiled clean so it should work for all of your purposes.
http://www.megaupload.com/?d=7A4NZWIP
 
Good idea. 

Come to think of it they might end up being at a really high relation of the start if the companion was.  My companions tend to stay at 90ish.  I bet they are still there when they become a lord.

I fixed the not being a marshal thing by adding one line to the script that activates player faction.

Hmm well they talk to me now but still aren't listening.  Right now they are acting like lords of a faction you are friendly with but aren't part or.  And the create party script is cloning the heroes.

EDIT2) IT WORKS!!!  Just had to wait a while.  Also had to edit a certain simple trigger above the main one.  But good old Casca from my mod appeared ready and willing to cause some destruction.  Now I just need to test the trigger that auto-disbands her party if she loses her castle.  Basically every week a trigger runs and checks if any of your companion lords have no powerbase.  If it finds one it disbands their party flags them as a companion and forces them into your party(even if it is full).  Combine this script with a quick tweak to let lords of a defeated faction join you and you are golden.  NE in an early version had there be a chance for lords of a wiped out faction to join your kingdom.  It was a matter of removing a couple lines from a script to implement.
 
Yeah so far I have the following accomplished.
Can make any companion you talk to with over 15 charisma become a companion lord if you have a town or castle to give them they now start at +30 relation to you. (done)
If they have over 8 leadership they get bonus renown and an even bigger army(done)
Lords of a defeated faction will have a chance to join your kingdom(done but not tested however should work)
If your companions lose their town or castle they will disband their army after a week and become a companion in their party again(done)
Bonus just to stir the pot I wrote a little trigger that assigns all lords on the map(including your companions a readiness of 99.  This will make them more prone to group together and form massive multilord armies.  It also helps your lords by making them almost entirely likely to continue following you and not run off.  Mine is set to happen every three months.(done)
The only thing that I have to test is that defeated lords of a faction do join your kingdom properly and make sure that your companions take your current flag for their own.

But I will post the full script in this thread and the share script thread for modders to use once I am done.
 
This will be great, but I'm a fan of managing your kingdom through a game menu. As far as I can tell, you are planning it through scripts and dialogs. Would you like me (after you release it) to port it to game menus, so you can choose how to manage? (And allowing bigger in-game freedom, too)
 
Sure.  I was going to do menus but I suck at making arrays and stuff so I didn't know how to select individual companions.  Whereas when you use dialogues you just use $g_talk_troop and the game knows who to deal with.  The main thing was to make sure that every companion lord had to get a castle or town.

So far everything else works I just need to test if villages are using the right culture now.
 
Ok the final steps to this have been kicking my ass. 
Two main problems. 
1)No matter what I do I can't seem to get the villages to switch to my new kingdom culture whether they belong to me or I have already given them to a vassal.  Here is what I am currently using for that purpose.
[(try_for_range, ":center_no", villages_begin, villages_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (try_begin),
        (eq,"$character_gender",tf_gutts),
        (party_set_slot, ":center_no", slot_center_culture,  "fac_culture_8"),
        (party_set_slot, ":center_no", slot_center_original_faction,  "fac_kingdom_8"),
        (party_set_slot, ":center_no", slot_center_ex_faction,  "fac_kingdom_8"),
        (else_try),
        (party_set_slot, ":center_no", slot_center_culture,  "fac_culture_9"),
        (party_set_slot, ":center_no", slot_center_original_faction,  "fac_kingdom_9"),
        (party_set_slot, ":center_no", slot_center_ex_faction,  "fac_kingdom_9"),###Setting the culture for the village isn't working.  They still only recruit ####the recruit type of their old faction.
        (try_end),
        (try_for_range,":troop_no", kingdom_heroes_begin, kingdom_heroes_end),
(party_get_slot, ":lord", ":center_no", slot_town_lord),
        (neq,":lord",":troop_no"),
        (call_script, "script_give_center_to_lord", ":center_no", "trp_player", 0),
        (try_end),
    ]),
2)I thought this was working but my trigger to disband a hero's party if they lose their castle is misfiring.  It should only fire when that heroes castle is captured.  I had it fire because I had a castle that I retained for myself.  Here is the trigger for that.
(24*7,0,0,[(assign,":num_centers",0),#Disband Centreless lords every week.  KINGDOM MANAGEMENT
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (val_add,":num_centers",1),
      (try_end),
      (assign,":num_lords",0),
      (try_for_range,":lord","trp_npc1","trp_kingdom_heroes_including_player_begin"),#Need to put all potential companions in a range.
        (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
        (val_add,":num_lords",1),
      (try_end),
      (try_begin),
      (lt,":num_lords",":num_centers")],#triggered when less centres than lords.  KINGDOM MANAGEMENT

[(try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":lord", ":center_no", slot_town_lord),
  (try_end),
  (try_for_range,":companion_lord","trp_npc1","trp_kingdom_heroes_including_player_begin"),#Need to put all potential companions in a range.
    (troop_slot_eq, ":companion_lord", slot_troop_occupation, slto_kingdom_hero),
    (neq,":lord",":companion_lord"),
    (troop_get_slot,":companion_army",":companion_lord",slot_troop_leaded_party),
    (remove_party,":companion_army"),
    (troop_set_slot,":companion_lord",slot_troop_occupation, slto_player_companion),
    (party_force_add_members,"p_main_party",":companion_lord",1),
    (display_message,"@The loss of their base of operations has forced one of your armies to disband.",0xFFFFFFAA),
    (try_end),
  ]),
      Hopefully someone knows what I am doing wrong here.
 
About the village problem, I think it would work to change the script_village_recruit_volunteers_recruit..

You will have to do the same in the mnu_recruit_volunteers, this script is only used when you recruit volunteers by talking to the village elder..

("village_recruit_volunteers_recruit",
    [
  (store_faction_of_party, ":center_faction", "$current_town"),
  (try_begin),
  (eq,":center_faction","fac_player_supporters_faction"),
  (faction_get_slot, ":volunteer_troop", "fac_player_supporters_faction", slot_faction_tier_1_troop),
  (else_try),

  (party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
  (try_end),
    (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
    (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
    (val_min, ":volunteer_amount", ":free_capacity"),
    (store_troop_gold, ":gold", "trp_player"),
    (store_div, ":gold_capacity", ":gold", 10),#10 denars per man
    (val_min, ":volunteer_amount", ":gold_capacity"),
    (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
    (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
    (store_mul, ":cost", ":volunteer_amount", 10),#10 denars per man
    (troop_remove_gold, "trp_player", ":cost"),
    ]),
 
Good idea.  I will do that then.  Thanks for the assist. 

I could have sworn the trigger I had to autodisband a lord party was firing correctly.  Maybe it was just a glitch.  Previously the companion party would only disband when the castle was taken.  I suspect the problem is here.

(party_get_slot, ":lord", ":center_no", slot_town_lord),#####Checks all centres to see which of the companions is a lord.
(try_for_range,":companion_lord","trp_npc1","trp_kingdom_heroes_including_player_begin"),#Need to put all potential companions in a range.###
    (troop_slot_eq, ":companion_lord", slot_troop_occupation, slto_kingdom_hero),###have been made a vassal###
    (neq,":lord",":companion_lord"),####finds any companion vassal that isn't also a town or castle lord this will be the one who is brought back into your party.

Oh one last problem I wrote a script that is supposed to make the villages of a centre you give to a companion belong to you.  But right now they revert to unowned when you assign the companion as the lord of a town or castle.  What the script is supposed to do is assign the player as the lord of those villages.

 
All the experiences in scripting I have says that if the script/trigger is simpler it have a bigger chance of working.. So in hope that might also work here I just made a simplified version of your trigger..

(24*7,0,0,[(assign,":num_centers",0),#Disband Centreless lords every week.  KINGDOM MANAGEMENT
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
        (store_faction_of_party, ":center_faction", ":center_no"),
        (eq, ":center_faction", "fac_player_supporters_faction"),
        (val_add,":num_centers",1),
      (try_end),
      (assign,":num_lords",0),
      (try_for_range,":lord","trp_npc1","trp_kingdom_heroes_including_player_begin"),#Need to put all potential companions in a range.
        (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
        (val_add,":num_lords",1),
      (try_end),
  # (try_begin), <-- what is a try begin doing there?
      (lt,":num_lords",":num_centers")],#triggered when less centres than lords.  KINGDOM MANAGEMENT

[(try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
    (store_faction_of_party, ":center_faction", ":center_no"),
    (eq, ":center_faction", "fac_player_supporters_faction"), #Only centers owned by player faction
  (try_for_range, ":companion", companions_begin, companions_end),
(troop_slot_eq,":companion",slot_troop_occupation, slto_kingdom_hero),#Companion needs to be a lord
    (try_begin),
(neg|troop_slot_eq,":companion",slot_town_lord,":center_no"),#Make him rejoin if he don't have a castle/town from the player faction
(troop_get_slot,":companion_army",":companion_lord",slot_troop_leaded_party),
    (remove_party,":companion_army"),
    (troop_set_slot,":companion_lord",slot_troop_occupation, slto_player_companion),
    (party_force_add_members,"p_main_party",":companion_lord",1),
    (display_message,"@The loss of their base of operations has forced one of your armies to disband.",0xFFFFFFAA),
(try_end),
  (try_end),
  (try_end),
  ]),
 
AWESOME.  That explains why the automatic disband script only recently stopped working properly.  I must have started to edit it then stopped and left the try begin there.  This led to the trigger firing when it shouldn't.

  And thanks for the little simplification to the check to see if a vassal companion has no town.  This should work but I'll let you know.

EDIT: I can't believe I didn't notice the companion range already had a slot defined in constants.
EDIT: You forgot to change companion_lord: to companion: in part of the script there but easy fix.
 
Just another thing I came to think about:

As far as I know, when you use "lt" (and also stuff like "eq", "gt", "ge" etc) it is the same as saying: value 1 is less than value 2..

So when you put in lets say (lt,":num_lords",":num_centers"), you actually make the trigger run when you have less lords than you have centers..

It might be me there is off track here, but I know that I use it the other way around in my scripts..

Berserker Pride said:
EDIT: You forgot to change companion_lord: to companion: in part of the script there but easy fix.

Woops, not good  :neutral:
 
You might be right with the less than.  I must have thought for half an hour which way was right.  I'll reverse it and see if it works properly.  Maybe I can add a debug message.


EDIT:I was missing a try end in my village return script.

EDIT: Ok I have all my code together I removed a couple of simple_triggers and combined then in the consequences of dialogue.  Now to test.
 
Berserker Pride said:
EDIT: Ok I have all my code together I removed a couple of simple_triggers and combined then in the consequences of dialogue.  Now to test.

I Hope it comes out well..
 
Back
Top Bottom