Mount & Blade Warband: Napoleonic Wars > Modifications

[Tutorial] Creating new unit section

(1/8) > >>

Gokiller:
[Tutorial] Creating a new unit section

I've been toying around a bit with the unit menu of NW the past hours. With some sweet results. (For someone who barely touches presentations etc) Considering I haven't really seen this in any mod currently I thought that I mind as well create a quick tutorial for it.

What is the advantage of a new section?
You can fit in a whole new bunch of units in the menu without scretching it out or anything. Simple and efficient. Especially for the modifications out there that could use the space!

This is the result we will be working towards in this tutorial:
Spoiler[close]

Files we will be edditing (coloured Green):
- module_strings
- module_presentations
- module_scripts
- module_constants

Section name
We shall be naming our new section "Bydanders" for the sake of whatever. You can change the name of your section to whatever you want. But you'll have to replace "bydanders".

Getting started
Let's start with module_strings as we will need to start with creating a new string to be used in the presentation.
This will be the name of the section.

Search for:
--- Code ---
("cavalry", "Cavalry"),
--- End code ---

Place under that:

--- Code ---
  ("bydanders", "Bydanders"),
--- End code ---

Now we will head to module_presentations to create the new section.
 
Search for:
--- Code ---
        (create_mesh_overlay, reg0, "mesh_white_plane"),
        (overlay_set_color, reg0, 0x000000),
        (overlay_set_alpha, reg0, 0xD0),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 660),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 5500),
        (position_set_y, pos1, 1600),
        (overlay_set_size, reg0, pos1),
--- End code ---

Place under that (leave one line between it)

--- Code ---
        (create_mesh_overlay, reg0, "mesh_white_plane"),
        (overlay_set_color, reg0, 0x000000),
        (overlay_set_alpha, reg0, 0xD0),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 610),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 5500),
        (position_set_y, pos1, 1600),
        (overlay_set_size, reg0, pos1),
--- End code ---

Search for:
--- Code ---
        (create_button_overlay, "$g_presentation_obj_select_cavalry", "str_cavalry", 0),
        (try_begin),
          (eq, "$g_multiplayer_select_presentation_unit_type", troop_select_type_cavalry),
          (overlay_set_color,"$g_presentation_obj_select_cavalry",0xECEB82),
        (else_try),
          (overlay_set_color,"$g_presentation_obj_select_cavalry",0xFFFFFF),
        (try_end),
        (position_set_x, pos1, 255),
        (position_set_y, pos1, 660),
        (overlay_set_position, "$g_presentation_obj_select_cavalry", pos1),
        #(position_set_x, pos1, 1500),
        #(position_set_y, pos1, 1500),
        #(overlay_set_size, "$g_presentation_obj_select_cavalry", pos1),
        (troop_set_slot,"trp_x_pos","$g_presentation_obj_select_cavalry",250),
        (troop_set_slot,"trp_y_pos","$g_presentation_obj_select_cavalry",660),
        (troop_set_slot,"trp_x_size","$g_presentation_obj_select_cavalry",1000),
        (troop_set_slot,"trp_y_size","$g_presentation_obj_select_cavalry",1000),
--- End code ---

Under that, (leave one line between it) place the following:

--- Code ---
        (create_button_overlay, "$g_presentation_obj_select_bydanders", "str_bydanders", 0),
        (try_begin),
          (eq, "$g_multiplayer_select_presentation_unit_type", troop_select_type_bydanders),
          (overlay_set_color,"$g_presentation_obj_select_bydanders",0xECEB82),
        (else_try),
          (overlay_set_color,"$g_presentation_obj_select_bydanders",0xFFFFFF),
        (try_end),
        (position_set_x, pos1, 370),
        (position_set_y, pos1, 610),
        (overlay_set_position, "$g_presentation_obj_select_bydanders", pos1),
        #(position_set_x, pos1, 1500),
        #(position_set_y, pos1, 1500),
        #(overlay_set_size, "$g_presentation_obj_select_bydanders", pos1),
        (troop_set_slot,"trp_x_pos","$g_presentation_obj_select_bydanders",300),
        (troop_set_slot,"trp_y_pos","$g_presentation_obj_select_bydanders",660),
        (troop_set_slot,"trp_x_size","$g_presentation_obj_select_bydanders",1000),
        (troop_set_slot,"trp_y_size","$g_presentation_obj_select_bydanders",1000),
--- End code ---

Search for:
--- Code ---
      (else_try),
          (eq,":object","$g_presentation_obj_select_cavalry"),
          (assign, "$g_multiplayer_select_presentation_unit_type",troop_select_type_cavalry),
          (presentation_set_duration, 0),
          (start_presentation,"prsnt_multiplayer_item_select"),
--- End code ---

Place under that:

--- Code ---
        (else_try),
  (eq,":object","$g_presentation_obj_select_bydanders"),
          (assign, "$g_multiplayer_select_presentation_unit_type",troop_select_type_bydanders),
          (presentation_set_duration, 0),
          (start_presentation,"prsnt_multiplayer_item_select"),
--- End code ---
(make sure that there is a (else_try) between this new section and the begin of the artillery section)

Next file: module_constants

Search for:
--- Code ---
troop_select_type_artillery
--- End code ---

Place under that:
--- Code ---
troop_select_type_bydanders = 4
--- End code ---

Now we will head to the last file, module_scripts in order to get units in the new section.

Search for:

--- Code ---
(assign,":unit_type",troop_select_type_artillery),
--- End code ---

Between that and (try_end) place this:

--- Code ---
(else_try),
  (is_between, ":troop_no", "trp_british_infantry2","trp_british_highlander"), # Brits

      (assign,":unit_type",troop_select_type_bydanders),
--- End code ---
(You can toy around with what units you want to be on it. At this moment we have the units british_infantry2 and british_highlander placed in the new section.

Run the build and check if they're errors, if none goodjob!

You can create more sections, just re-do the above steps and toy around a bit with the positioning of the string and box.

Hope this helps, there could be a tiny possibility that there could be a mistake in there. If so and noticed please inform me so it can be rapidly adjusted. My first somewhat modding tutorial so mistakes are expected to be made.  :-X

If there are any questions feel free to ask them!

Cheers,
Gokiller

Parrot:
Very useful! Well written as well, easy to follow...

Gokiller:
Quickly added a forgotten part that involved the module_constants file 

Mercuri:
It's possible to have the "bylanders" Unit Section at the same level as the other Unit Sections are? Or it's not possible and it may be below the Specialist class?

Gokiller:
I´m sure that is possible. You just need to toy around a bit with the sizes of the other sections and shuffle them to the left or right to fit the fourth one in.

I did it on this way: Below the first three, because it has a sweet look. But if you want you can place the button/section where ever you want. You also need to play around a bit with the location.

Navigation

[0] Message Index

[#] Next page

Go to full version