Banners

Users who are viewing this thread

-John25-

G'day, how to make lords use their faction's banner instead of their own one?
 
Runea said:
This code makes it so all generals/counts in the faction use the same banner as their faction leader without having to have a ton of copies of that banner.  I needed it for my mod where the faction mattered more than the individual; and also so armies look more unified under that one banner.

Atm, I believe the banner will carry over even if they exile/defect to another faction; not sure how to fix that.  Assuming exiled generals don't get a castle or town, it won't be noticeable; and hopefully not enough lords will defect to make things odd :razz:

Code:
            #faction banners
      (faction_set_slot, "fac_kingdom_1", slot_faction_banner, "mesh_banner_f09"),
      (faction_set_slot, "fac_kingdom_2", slot_faction_banner, "mesh_banner_kingdom_f"),
      (faction_set_slot, "fac_kingdom_3", slot_faction_banner, "mesh_banner_kingdom_c"),
      (faction_set_slot, "fac_kingdom_4", slot_faction_banner, "mesh_banner_f10"),
      (faction_set_slot, "fac_kingdom_5", slot_faction_banner, "mesh_banner_kingdom_e"),
      (faction_set_slot, "fac_kingdom_6", slot_faction_banner, "mesh_banner_kingdom_a"),


##Run code start here

(try_for_range, ":cur_faction", npc_kingdoms_begin, npc_kingdoms_end),
        (faction_get_slot, ":cur_faction_king", ":cur_faction", slot_faction_leader),
        (faction_get_slot, ":cur_faction_banner", ":cur_faction", slot_faction_banner),
        (val_sub, ":cur_faction_banner", banner_meshes_begin),
        (val_add, ":cur_faction_banner", banner_scene_props_begin),
        (troop_set_slot, ":cur_faction_king", slot_troop_banner_scene_prop, ":cur_faction_banner"),
      (try_end),
  #    (assign, ":num_khergit_lords_assigned", 0),
  #    (assign, ":num_sarranid_lords_assigned", 0),
  #    (assign, ":num_other_lords_assigned", 0),

      (try_for_range, ":kingdom_hero", active_npcs_begin, active_npcs_end),
        (this_or_next|troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_kingdom_hero),
        (troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_inactive_pretender),

        (store_troop_faction, ":kingdom_hero_faction", ":kingdom_hero"),
        (neg|faction_slot_eq, ":kingdom_hero_faction", slot_faction_leader, ":kingdom_hero"),
#        (try_begin), 
#          (eq, ":kingdom_hero_faction", "fac_kingdom_3"), #Khergit Khanate
          #(store_add, ":kingdom_3_banners_begin", banner_scene_props_begin, khergit_banners_begin_offset),
          #(store_add, ":banner_id", ":kingdom_3_banners_begin", ":num_khergit_lords_assigned"),
#          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner_id"),
          #(val_add, ":num_khergit_lords_assigned", 1),
#        (else_try),
#          (eq, ":kingdom_hero_faction", "fac_kingdom_6"), #Sarranid Sultanate
          #(store_add, ":kingdom_6_banners_begin", banner_scene_props_begin, sarranid_banners_begin_offset),
          #(store_add, ":banner_id", ":kingdom_6_banners_begin", ":num_sarranid_lords_assigned"),
#          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner_id"),
#          (val_add, ":num_sarranid_lords_assigned", 1),
#        (else_try),
#          (assign, ":hero_offset", ":num_other_lords_assigned"),
#          (try_begin),
#            (gt, ":hero_offset", khergit_banners_begin_offset),#Do not add khergit banners to other lords
#            (val_add, ":hero_offset", khergit_banners_end_offset),
#            (val_sub, ":hero_offset", khergit_banners_begin_offset),
#          (try_end),
#          (try_begin),
#            (gt, ":hero_offset", sarranid_banners_begin_offset),#Do not add sarranid banners to other lords
#            (val_add, ":hero_offset", sarranid_banners_end_offset),
#            (val_sub, ":hero_offset", sarranid_banners_begin_offset),
#          (try_end),
#          (store_add, ":banner_id", banner_scene_props_begin, ":hero_offset"),
#          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner_id"),
#          (val_add, ":num_other_lords_assigned", 1),
#        (try_end),

        (try_begin), 
          (eq, ":kingdom_hero_faction", "fac_kingdom_1"), #Swadia
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_1", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_2"), #Vaegir
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_2", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_3"), #Khergit Khanate
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_3", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_4"), #Nords
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_4", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_5"), #Rhodok
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_5", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_6"), #Sarannid
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_6", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (try_end),

    #    (try_begin),
    #      (this_or_next|lt, ":banner_id", banner_scene_props_begin),
    #      (gt, ":banner_id", banner_scene_props_end_minus_one),
    #      (display_message, "@{!}ERROR: Not enough banners for heroes!"),
    #    (try_end),

##Run code end here

        (store_character_level, ":level", ":kingdom_hero"),
        (store_mul, ":renown", ":level", ":level"),
        (val_div, ":renown", 4), #for top lord, is about 400

		(troop_get_slot, ":age", ":kingdom_hero", slot_troop_age),
        (store_mul, ":age_addition", ":age", ":age"),
        (val_div, ":age_addition", 8), #for top lord, is about 400
		(val_add, ":renown", ":age_addition"),

It works with more than 6 factions as well, just add another

Code:
        (else_try),
          (eq, ":kingdom_hero_faction", "fac_kingdom_7"), #New Faction
          (faction_get_slot, ":cur_faction_banner", "fac_kingdom_7", slot_faction_banner),
          (val_sub, ":cur_faction_banner", banner_meshes_begin),
          (val_add, ":cur_faction_banner", banner_scene_props_begin),
          (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":cur_faction_banner"),
        (try_end),

code section and bump up the number to 7, then paste it again for 8, etc.  Just make sure the "(try_end)," is after the last one and not after any others.

And these simple triggers will update lords banner to their current faction. Centers will also have their banner updated

Code:
    #Eagle
    (24, #Updates every lord's banner to their current faction.
   [
        (try_for_range, ":lord_no", active_npcs_begin, active_npcs_end),
            (this_or_next|is_between, ":lord_no", lords_begin, lords_end),
            (is_between, ":lord_no", companions_begin, companions_end),
            (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero),
            (store_faction_of_troop, ":lords_faction", ":lord_no"),
            (faction_get_slot, ":lords_king", ":lords_faction", slot_faction_leader),
            (troop_get_slot, ":faction_banner", ":lords_king", slot_troop_banner_scene_prop),
            (troop_set_slot, ":lord_no", slot_troop_banner_scene_prop, ":faction_banner"),
        (try_end),
    ]),

  (24, #Updates every town/castle's banner to their current faction.
   [
       (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
            (party_get_slot, ":town_lord", ":center_no", slot_town_lord),
            (gt, ":town_lord", 0),
            (troop_get_slot, ":faction_banner", ":town_lord", slot_troop_banner_scene_prop),
            (gt, ":faction_banner", 0),
            (val_sub, ":faction_banner", banner_scene_props_begin),
            (val_add, ":faction_banner", banner_map_icons_begin),
            (party_set_banner_icon, ":center_no", ":faction_banner"),
       (try_end),
  ]),
    #Eagle
 
Back
Top Bottom