WB Coding 1heraldic banner per faction

Users who are viewing this thread

LoneFennec

Recruit
I know Lav's Fish&Chip does that, my idea was to lower the banners used for map_icon using the heraldic one, and at the same time using 1 banner per faction code to use it, but the problem seems with that script since it doesn't check and change when a lord defect to a new faction, I'm bad at scripting so I'm testing and learning till I manage to get it to work. Here is the link for that code, that might make you have pity on this poor soul and gime a suggestion on how to do that(new script): https://forums.taleworlds.com/index.php?threads/python-script-scheme-exchange.8652/post-5369824
Quoted the above from the Discord server, and was advised to start a post here.

Can someone enlighten me or show me the way on how to do the above?
wanting 1 heraldic banner per 1 faction that when one lord defect he change to his new faction banner.

Hope someone can help, thanks!
 

Vetrogor

Squire
1) Assigning all lords a kingdom banner.
Find this
Python:
# Assign banners and renown.
# We assume there are enough banners for all kingdom heroes.

      #faction banners
      (faction_set_slot, "fac_kingdom_1", slot_faction_banner, "mesh_banner_kingdom_f"),
      (faction_set_slot, "fac_kingdom_2", slot_faction_banner, "mesh_banner_kingdom_b"),
      (faction_set_slot, "fac_kingdom_3", slot_faction_banner, "mesh_banner_kingdom_c"),
      (faction_set_slot, "fac_kingdom_4", slot_faction_banner, "mesh_banner_kingdom_a"),
      (faction_set_slot, "fac_kingdom_5", slot_faction_banner, "mesh_banner_kingdom_d"),
      (faction_set_slot, "fac_kingdom_6", slot_faction_banner, "mesh_banner_kingdom_e"),

Paste code
Python:
      (try_for_range, ":kingdom_hero", active_npcs_begin, active_npcs_end),
        (troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_kingdom_hero),
        (store_troop_faction, ":kingdom_hero_faction", ":kingdom_hero"),
        (faction_get_slot, ":banner", ":kingdom_hero_faction", slot_faction_banner),
        (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner"),
      (try_end),
And delete code after
Python:
      (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),
          (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),

2) Lord joins faction
Find
Python:
      (troop_set_faction, ":troop_no", ":faction_no"),
      (troop_set_slot, ":troop_no", slot_troop_recruitment_random, 0),
      (troop_set_slot, ":troop_no", slot_lord_recruitment_argument, 0),
      (troop_set_slot, ":troop_no", slot_lord_recruitment_candidate, 0),
      (troop_set_slot, ":troop_no", slot_troop_promised_fief, 0),

and paste code below
Python:
      (faction_get_slot, ":banner", ":faction_no", slot_faction_banner),
      (troop_set_slot, ":troop_no", slot_troop_banner_scene_prop, ":banner"),

3) Find and fix possible bugs. For example, for claymant quest or rebellion.
 
Last edited:
Upvote 0

LoneFennec

Recruit
1) Assigning all lords a kingdom banner.
Find this
Python:
# Assign banners and renown.
# We assume there are enough banners for all kingdom heroes.

      #faction banners
      (faction_set_slot, "fac_kingdom_1", slot_faction_banner, "mesh_banner_kingdom_f"),
      (faction_set_slot, "fac_kingdom_2", slot_faction_banner, "mesh_banner_kingdom_b"),
      (faction_set_slot, "fac_kingdom_3", slot_faction_banner, "mesh_banner_kingdom_c"),
      (faction_set_slot, "fac_kingdom_4", slot_faction_banner, "mesh_banner_kingdom_a"),
      (faction_set_slot, "fac_kingdom_5", slot_faction_banner, "mesh_banner_kingdom_d"),
      (faction_set_slot, "fac_kingdom_6", slot_faction_banner, "mesh_banner_kingdom_e"),

Paste code
Python:
      (try_for_range, ":kingdom_hero", active_npcs_begin, active_npcs_end),
        (troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_kingdom_hero),
        (store_troop_faction, ":kingdom_hero_faction", ":kingdom_hero"),
        (faction_get_slot, ":banner", ":kingdom_hero_faction", slot_faction_banner),
        (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner"),
      (try_end),
And delete code after
Python:
      (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),
          (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),

2) Lord joins faction
Find
Python:
      (troop_set_faction, ":troop_no", ":faction_no"),
      (troop_set_slot, ":troop_no", slot_troop_recruitment_random, 0),
      (troop_set_slot, ":troop_no", slot_lord_recruitment_argument, 0),
      (troop_set_slot, ":troop_no", slot_lord_recruitment_candidate, 0),
      (troop_set_slot, ":troop_no", slot_troop_promised_fief, 0),

and paste code below
Python:
      (faction_get_slot, ":banner", ":faction_no", slot_faction_banner),
      (troop_set_slot, ":troop_no", slot_troop_banner_scene_prop, ":banner"),

3) Find and fix possible bugs. For example, for claymant quest or rebellion.

EDIT: apparently it doesn't work properly. The banners will change inside the castle normally, but lords and castles/towns never change the banner. plus the banner seems randomized, so each start each clan has a flag.

EDIT 2: fixed the randomization of banners. But still no luck in the banner changing, it seems like they don't check or update the banners at all.
 
Last edited:
Upvote 0

LoneFennec

Recruit
I made some progress, now the lords change banner when defecting to a clan, all of them change to 1 specific banner as you will see in the picture below, castles and towns change their banner to the new lords new banner, not sure if it will work a 2nd time.
it's still buggy as they all change to one random banner, not sure if they will change again if they change clan again, and sometimes they don't change, needs more testing.
iANmFNT.png
The lords with the yellow eagle flags are lords defected from the Akamatsu clan(the faction being besieged) to Amago clan (the faction doing the besieging)
I've been messing around with the codes I've found in the forum, trying this and that, understanding what this and that do. and apparently doing this will give the results I have so far.
Python:
    ("initialize_troop_banners",
    [        
######## WOTS one banner per faction start ########
      #faction banners
      (faction_set_slot, "fac_kingdom_1", slot_faction_banner, "mesh_banner_Akamatsu"),  #Akamatsu Clan
      (faction_set_slot, "fac_kingdom_2", slot_faction_banner, "mesh_banner_Akizuki"),   #Akizuki Clan
      (faction_set_slot, "fac_kingdom_3", slot_faction_banner, "mesh_banner_Amago"),     #Amago Clan
      (faction_set_slot, "fac_kingdom_4", slot_faction_banner, "mesh_banner_Anegakoji"), #Anegakoji Clan
      (faction_set_slot, "fac_kingdom_5", slot_faction_banner, "mesh_banner_Anto"),      #Anto Clan
      (faction_set_slot, "fac_kingdom_6", slot_faction_banner, "mesh_banner_Arima"),     #Arima Clan
   
      (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),

      (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_1"), #Akamatsu Clan
          (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"), #Akizuki Clan
          (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"), #Amago Clan
          (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"), #Anegakoji Clan
          (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"), #Anto Clan
          (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"), #Arima Clan
          (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_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),######## WOTS one banner per faction end ########
      ]),
Python:
######## WOTS one banner per faction start ########
    ### Change banner start ###
      (try_for_range, ":cur_faction", npc_kingdoms_begin, npc_kingdoms_end),
        (faction_get_slot, ":cur_faction_banner", ":cur_faction", slot_faction_banner),
        (faction_get_slot, ":banner", ":faction_no", slot_faction_banner),
        (troop_set_slot, ":troop_no", slot_troop_banner_scene_prop, ":banner"),
        # (val_sub, ":cur_faction_banner", clans_banner_meshes_begin),
        # (val_add, ":cur_faction_banner", clans_banner_scene_props_begin),
        (troop_set_slot, ":troop_no", slot_troop_banner_scene_prop, ":cur_faction_banner"),
      (try_end),
    ### Change banner end ###
######## WOTS one banner per faction end ########

what do you think? is there a way to improve it?
Thanks!
 
Last edited:
Upvote 0
Top Bottom