Adding Banners

Users who are viewing this thread

Somewhat of a noob question here, but is there any way for me to add a banner to a game and modify it so that it cannot be selected by any NPCs?

Whenever I replace a banner, it always gets used by other Lords, which is kind of frustrating. Also, why are there duplicate banners in the last page of the banner select screen?


Been trying to figure this one out for awhile, but so far I've got nothing. Thanks for the help!
 
0.960?

I haven't play the new version yet. I don't know if any change to the number of flag available. In 0.95x, there wasn't enough for everyone, so some had to share flag (the duplicated ones in the last page).

Also, I haven't take a look at the module system for 0.960 yet, so don't know what changes there are.

Back to the question: this was possible in earlier version and I would expect it to be the same or similar in this version. To mod in new flags, you will need a few tools.

- BRF Editor: to import new textures and to create new meshes (mesh names) for those flags.
http://forums.taleworlds.com/index.php/topic,8771.0.html

- Module System: this is a must since you will need to edit a several files. You will also need to install and setup Python for compiling new txt files.
Module system: http://forums.taleworlds.com/index.php/topic,39256.0.html
Python: http://www.python.org/download/
Setting up Python: http://forums.taleworlds.com/index.php/topic,35044.0.html

- DDS converter: to convert your texture file to DDS format to be used in the game. You might be able to bypass this process if you have a photo editor program (such as Adobe Photoshop) that support DDS plug-in which allow you to edit DDS file directly.
http://eliteforce2.filefront.com/file/DDS_Converter;29412 (v2.1 from the old link I found. Don't know if there is new one or not)

If you have more flag than NPCs (110 NPCs?), some of the flags will never be used by NPCs.

Need more?
 
1) Create new textures for your new flags.

2) Use BRF Editor to create new mesh name and assign new texture for your flags.

3) Edit module_map_icons.py to add new flags to the game:

Part of the code will look like this:

Code:
  ("banner_103",0,"map_flag_e19", banner_scale,0),
  ("banner_104",0,"map_flag_e20", banner_scale,0),
  ("banner_z1",0,"map_flag_e16", banner_scale,0),
  ("banner_z2",0,"map_flag_e17", banner_scale,0),
  ("banner_z3",0,"map_flag_e18", banner_scale,0),
  ("banner_z4",0,"map_flag_e19", banner_scale,0),
  ("banner_z5",0,"map_flag_e20", banner_scale,0),
  ("banner_105",0,"map_flag_15", banner_scale,0),

Add new ones at the end.

"flag name (unique in game)",0,"mesh name",banner_scale,0

4) Edit module_meshes.py to specify how you new flag appear/look in game. This file looks different from the older one, so I may have to try myself. Anyway, first try to add your new one at the end.

Part of the code:

Code:
  ("banners_default_a", 0, "banners_default_a", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_b", 0, "banners_default_b", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_c", 0, "banners_default_c", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_d", 0, "banners_default_d", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_e", 0, "banners_default_e", 0, 0, 0, -90, 0, 0, 1, 1, 1),

Again, flag in game name then mesh name. Don't change any thing else.

If this doesn't work well, then you may need to make some changes in other part of this module.

5) Edit scene_props.py

Part of the code:

Code:
  ("banner_z2",0,"banner_e17","0", []),
  ("banner_z3",0,"banner_e18","0", []),
  ("banner_z4",0,"banner_e19","0", []),
  ("banner_z5",0,"banner_e20","0", []),
  ("banner_eu",0,"banner_a15","0", []),

Use this format but add the new one at the bottom. You can add the new flags at the end of the banner list, but this will make your current save incompatible. Furthermore, it may create problems with the scenes.

6) Edit module_presentations.py to display your flags in pages so you can select it.

From line 181, the entire code looks like this:

("banner_selection",0,mesh_load_window,[
      (ti_on_presentation_load,
      [(set_fixed_point_multiplier, 1000),
        (str_store_string, s1, "str_banner_selection_text"),
        (create_text_overlay, reg1, s1, tf_center_justify),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 600),
        (overlay_set_position, reg1, pos1),
        (create_button_overlay, "$g_presentation_obj_1", "@Next Page", tf_center_justify),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 50),
        (overlay_set_position, "$g_presentation_obj_1", pos1),

        (assign, ":mad:_pos", 150),
        (assign, ":y_pos", 575),
        (assign, ":try_end", banner_meshes_end_minus_one),
        (store_mul, ":begin_mesh", 16, "$g_presentation_page_no"),
        (val_add, ":begin_mesh", banner_meshes_begin),
        (store_add, ":try_end_2", ":begin_mesh", 16),
        (val_min, ":try_end", ":try_end_2"),
        (store_add, "$g_presentation_banner_start", "$g_presentation_obj_1", 1),
        (try_for_range, ":cur_banner_mesh", ":begin_mesh", ":try_end"),
          (create_image_button_overlay, reg1, ":cur_banner_mesh", ":cur_banner_mesh"),
          (position_set_x, pos1, ":mad:_pos"),
          (position_set_y, pos1, ":y_pos"),
          (overlay_set_position, reg1, pos1),
          (position_set_x, pos1, 100),
          (position_set_y, pos1, 100),
          (overlay_set_size, reg1, pos1),
          (val_add, ":mad:_pos", 100),
          (ge, ":mad:_pos", 900),
          (assign, ":mad:_pos", 150),
          (val_sub, ":y_pos", 250),
        (try_end),
        (presentation_set_duration, 999999),
        ]),
      (ti_on_presentation_event_state_change,
      [(store_trigger_param_1, ":eek:bject"),
        (try_begin),
          (eq, ":eek:bject", "$g_presentation_obj_1"),
          (val_add, "$g_presentation_page_no", 1),
          (val_mod, "$g_presentation_page_no", 7),  #7 is the number of pages. Take you total number of flag divided by 16 then round up to get the number of pages
          (start_presentation, "prsnt_banner_selection"),
        (else_try),
          (store_sub, ":selected_banner", ":eek:bject", "$g_presentation_banner_start"),
          (store_mul, ":page_adder", 16, "$g_presentation_page_no"),
          (val_add, ":selected_banner", ":page_adder"),
          (store_add, ":selected_banner_map_icon", ":selected_banner", banner_map_icons_begin),
          (party_set_banner_icon, "p_main_party", ":selected_banner_map_icon"),
          (store_add, ":selected_banner_spr", ":selected_banner", banner_scene_props_begin),
          (troop_set_slot, "trp_player", slot_troop_banner_scene_prop, ":selected_banner_spr"),
          (presentation_set_duration, 0),
          (assign, ":troop_to_change", 0),
          (assign, ":end_cond", kingdom_heroes_end),
          (try_for_range, ":cur_troop", kingdom_heroes_begin, ":end_cond"),
            (troop_slot_eq, ":cur_troop", slot_troop_banner_scene_prop, ":selected_banner_spr"),
            (assign, ":troop_to_change", ":cur_troop"),
            (assign, ":end_cond", 0),
            (troop_set_slot, ":cur_troop", slot_troop_banner_scene_prop, banner_scene_props_end_minus_one),
            (troop_get_slot, ":cur_party", ":cur_troop", slot_troop_leaded_party),
            (gt, ":cur_party", 0),
            (party_set_banner_icon, ":cur_party", banner_map_icons_end_minus_one),
          (try_end),
          (try_for_range, ":cur_center", walled_centers_begin, walled_centers_end),
            (try_begin),
              (party_slot_eq, ":cur_center", slot_town_lord, "trp_player"),
              (party_set_banner_icon, ":cur_center", ":selected_banner_map_icon"),
            (else_try),
              (party_slot_eq, ":cur_center", slot_town_lord, ":troop_to_change"),
              (party_set_banner_icon, ":cur_center", banner_map_icons_end_minus_one),
            (try_end),
          (try_end),
        (try_end),
        ]),
      (ti_on_presentation_run,
      [(try_begin),
          (this_or_next|key_clicked, key_space),
          (this_or_next|key_clicked, key_enter),
          (this_or_next|key_clicked, key_escape),
          (key_clicked, key_back_space),
          (presentation_set_duration, 0),
        (try_end),

        ]),
      ]),

Change the number of pages (noted in blue). The rest of the code seem to just deal with reassigning flag to NPCs in case you selected their flag.

I think I cover all of the files need editting. The editting details may not be entirely correct because I base this on my experiences in older modules.

If you get errors that you can't figure out, post it here. I, or some one else, will try to help.
 
Thanks again for the help, but for some reason "paint mode" doesn't seem to want to work and I am unable to modify the mesh. I made an exported copy of one of the Native banners that I'm trying to edit over, but here's where I'm stuck-

boo-1.jpg


Where do I go from here?
 
Note: I will go with the simplier method that don't required you to create resources for Mod. All new resource will be placed with Native. However, you should back up "Textures", and "CommonRes" folders and create "Your_Mod_Name" folder for your text files that are generated from module system.

The easiest way to add new flag is to modify the existing one.

1) Copy one of the existing flag texture from Mount&Blade\Textures\..

For example, copy the "banners_a.dds" and rename it to "banners_f.dds". Use DDS converter to convert dds file to the format you can work with. Use your favorite image editing software to edit this file. if you don't have any image editting software, try Gimp (I think it's free).

Gimp:  http://www.gimp-tutorials.com/index.php

If you have Adobe Photoshop, Nvidia PhotoShop dds plug in:  http://developer.nvidia.com/object/nv_texture_tools.html

If you want to, you can request someone to make the flag texture for you:

http://forums.taleworlds.com/index.php/topic,27335.0.html

When you have the texture file in dds format, put it back to the "Textures" folder.

2) Use BRF Editor to open "textures.brf" (...Mount&Blade\CommonRes\...). Select "banner_a" and make a clone (the "Clone" button is below the list). The cloned texture name will be at the bottom of the list. Select it then change the texture name to whatever you use in step 1, ie "banner_f.dds". Click set to apply the change then save.

3) Similarly, use BRF Editor to open "materials.brf" from the same place. Make a clone of the materials name from "banners_a". Change the name and set the diffuse (diffuse is the texture name in step 2 without the dds extension). Set then save.

4) Use BRF Editor to create new mesh and assign texture:

- Open "banners.brf" (...Mount&Blade\CommonRes\..), note the banner that is on the texture file that you made a copy of. For example, "banners_a.dds" will have mesh name from "banner_a01" to "banner_a21" all assign to the dds file.

- Select a banner mesh, then use the "Clone" function of BRF Editor to make a copy. The copy will be place at the bottom. Go to the bottom and select the cloned mesh. Change the name, ie "banner_f01" and assign the texture which is "banners_f" or what ever the name you used above. Set then save.

- Similarly, open "map_flags.brf", "map_flags_b.brf" and "map_flags_c.brf". Clone the one that appear on the texture file that you used to make a copy, ie "banner_a". Change the name and the texture. Set then save. Note the new mesh names because you will need them to edit the module files.

Now, you are ready to edit the module system.

Good luck.

 
Did all the editing and I think everything worked out fine.

flag1.jpg


I think I'm having trouble with the coding though, here's how they look-


module_map_icons

Code:
("banner_f12",0,"map_flag_f12", banner_scale,0),

module_meshes- I didn't really know what to do here so I just added f12 at the end of the previous thing since it looked like it lined up with the previous ones.

Code:
  ("banner_z5", 0, "banner_e20", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banner_e21", 0, "banner_a15", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banner_f12", 0, "banner_f12", 0, 0, 0, -90, 0, 0, 1, 1, 1),


  ("banners_default_a", 0, "banners_default_a", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_b", 0, "banners_default_b", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_c", 0, "banners_default_c", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_d", 0, "banners_default_d", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_e", 0, "banners_default_e", 0, 0, 0, -90, 0, 0, 1, 1, 1),
  ("banners_default_f", 0, "banners_default_f", 0, 0, 0, -90, 0, 0, 1, 1, 1),

module_scene_props
Code:
  ("banner_f12",0,"banner_f12","0", []),
 
It really doesn't matter where you put your ModuleSystem folder (the one contain all *.py files). However, you should edit the "module_info.py" to output the files to where you want them.

Code:
# Point export_dir to the folder you will be keeping your module
# Make sure you use forward slashes (/) and NOT backward slashes (\)

export_dir = "C:/Program Files/Mount&Blade/Modules/Native/"

By default, it outputs to your "Native" folder. That means it will overwrite your original. If you don't want that, just create a mod folder in the "Module" folder (make a copy of Native then rename it).

Then change the output destination in "module_info.py".

After you are done with coding, run the "build_module.bat"

If you get some errors, run the bat again to see if some of the errors will disappear. That happens when you edit multiple related files at the same time.

 
Aha. That makes perfect sense. Only problem is python just doesn't seem to want to work.

I added

C:\Python25
;C:\Python25
";C:\Python25" to my environmental variables, and still I get the internal or external command error.
 
Windows XP or Vista?

Did you add it to User Variables or System Variables. I used System Variable. Edit the "Path" line and add

;C:\Python25
 
It's almost as if there's an artificial limit as to the number of flags available at the select screen and the game won't let me go over it.

I know the banner works correctly, as I was able to overwrite a standard banner with the mesh name and icon of my custom one and it displayed just fine at the banner select screen. The only problem is getting these banners in addition to the standard ones without making replacements.
 
Aha! I've got it! You have to change module_constants.

Code:
# Banner constants

banner_meshes_begin = "mesh_banner_a01"
banner_meshes_end_minus_one = "mesh_banner_f13"

custom_banner_charges_begin = "mesh_custom_banner_charge_01"
custom_banner_charges_end = "mesh_tableau_mesh_custom_banner"

custom_banner_backgrounds_begin = "mesh_custom_banner_bg"
custom_banner_backgrounds_end = custom_banner_charges_begin

custom_banner_flag_types_begin = "mesh_custom_banner_01"
custom_banner_flag_types_end = custom_banner_backgrounds_begin

custom_banner_flag_map_types_begin = "mesh_custom_map_banner_01"
custom_banner_flag_map_types_end = custom_banner_flag_types_begin

custom_banner_flag_scene_props_begin = "spr_custom_banner_01"
custom_banner_flag_scene_props_end = "spr_banner_a"

custom_banner_map_icons_begin = "icon_custom_banner_01"
custom_banner_map_icons_end = "icon_banner_01"

banner_map_icons_begin = "icon_banner_01"
banner_map_icons_end_minus_one = "icon_banner_f13"

banner_scene_props_begin = "spr_banner_a"
banner_scene_props_end_minus_one = "spr_banner_eu"

khergit_banners_begin_offset = 63
khergit_banners_end_offset = 84

Did the trick. Thanks so much for the help!
 
Hmm the way some banners are reserved are weird.
a15 seems to be swapped with e21, and there are z1 to z5...
 
Ya, they are swapped in the module_system.  This is because they want a certain lord to have the banner, and the game assigns banners in the order troops appear in the module system, although it is different for the Khergit's and their banners.
 
This is a good beginning to the adding of a banner, but I have a few questions.

I successfully added a new banner to the game as a test. but problem now is, the heraldic armor/shields will not switch over to my banner color, how can I fix that?

Also another bigger problem is. that the map icon doesn't show that I m flying my new banner, it's as if I had no banner at all. What to do pls help?
 
The background heraldic colors are set by the banner background color, not the color of the banner.  This is set in the first script.  The banner should still show on the map, but know that there are 2 banners for the map that are coded wrong.  I found this out since I remade the first 64 banners myself for my mod.  I think it was 7 and 21.  For your test, use the 3rd banner image.
 
Back
Top Bottom