MP Tutorial Module System Adding a new multiplayer faction tutorial

Users who are viewing this thread

Sorry for necro post, but I have a problem. I'm doing this in Napoleonic Wars, and when I try hosting a game with my two custom factions it just starts with Russia and Austria like this

VZs8u.jpg

and

sfE69.jpg

Would anyone who knows how to mod NW please help me? I'm a noob at modding :sad:
 
Chosen1 said:
Sorry for necro post, but I have a problem. I'm doing this in Napoleonic Wars, and when I try hosting a game with my two custom factions it just starts with Russia and Austria like this

VZs8u.jpg

and

sfE69.jpg

Would anyone who knows how to mod NW please help me? I'm a noob at modding :sad:

You can easily change the factions to the ones you want by going to the Administrator panel in-game. Alternatively, if you want only your custom factions to exist, you can put all of the default factions under this line of code:

Code:
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),

So it would look something like this:

Code:
  ("custom_faction_1",  "Team 1", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("custom_faction_2",  "Team 2", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),
  ("kingdom_1",  "Kingdom of Swadia", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdom_2",  "Kingdom of Vaegirs",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCCBB99),
  ("kingdom_3",  "Khergit Khanate", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCC99FF),
  ("kingdom_4",  "Kingdom of Nords",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DDDD),
  ("kingdom_5",  "Kingdom of Rhodoks",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DD33),
  ("kingdom_6",  "Sarranid Sultanate",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),

If you do this though, there will be NO way to select the other factions in-game.
 
Nord Champion said:
Code:
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),

So it would look something like this:

Code:
  ("custom_faction_1",  "Team 1", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("custom_faction_2",  "Team 2", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),
  ("kingdom_1",  "Kingdom of Swadia", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdom_2",  "Kingdom of Vaegirs",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCCBB99),
  ("kingdom_3",  "Khergit Khanate", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCC99FF),
  ("kingdom_4",  "Kingdom of Nords",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DDDD),
  ("kingdom_5",  "Kingdom of Rhodoks",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DD33),
  ("kingdom_6",  "Sarranid Sultanate",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),
what file do i go into to edit that?
 
Kryptea said:
Nord Champion said:
Code:
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),

So it would look something like this:

Code:
  ("custom_faction_1",  "Team 1", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("custom_faction_2",  "Team 2", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdoms_end","{!}kingdoms_end", 0, 0,[], []),
  ("kingdom_1",  "Kingdom of Swadia", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xEE7744),
  ("kingdom_2",  "Kingdom of Vaegirs",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCCBB99),
  ("kingdom_3",  "Khergit Khanate", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCC99FF),
  ("kingdom_4",  "Kingdom of Nords",    0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DDDD),
  ("kingdom_5",  "Kingdom of Rhodoks",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0x33DD33),
  ("kingdom_6",  "Sarranid Sultanate",  0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xDDDD33),
what file do i go into to edit that?

Module_Factions.
 
I have been reading out many of your articles and I can ask pretty nice stuff, I will spend more time learning about this topic. I like travel and use play on frivmini.com
 
Hate to necro considering the last reply was 6 months ago, but I have a question...

Is there any way to do this while retaining compatability with Native clients?  That is, without anyone having to download anything.
 
Sorry for restarting this thread 6 years later lol, but I'm facing an interesting issue
I have added three factions #7, 8, and 9 to Warband multiplayer. If I want to use them as Team 1 Faction, everything works well. But if I want to use them as Team 2 Faction, only faction #9 works (when I select Faction #7 or 8 the game doesn't accept it and automatically selects Swadia/Vaegir). The codes are the same for all three factions so I am unsure about what's causing the issue

Another interesting point, when I delete all the codes that are related to Factions #7 and 8 but change nothing to Faction #9's coding, the same issue appears with Faction #9: I can't select it for Team 2 Faction anymore
 
Last edited:
Sorry for restarting this thread 6 years later lol, but I'm facing an interesting issue
I have added three factions #7, 8, and 9 to Warband multiplayer. If I want to use them as Team 1 Faction, everything works well. But if I want to use them as Team 2 Faction, only faction #9 works (when I select Faction #7 or 8 the game doesn't accept it and automatically selects Swadia/Vaegir). The codes are the same for all three factions so I am unsure about what's causing the issue

Another interesting point, when I delete all the codes that are related to Factions #7 and 8 but change nothing to Faction #9's coding, the same issue appears with Faction #9: I can't select it for Team 2 Faction anymore
Not sure if you already fixed your issue or not. The guide worked well for me, so perhaps restart again, you might have missed a detail.
 
I have changed factions' names to make the issue easier to notice:
Screenshot 1
Screenshot 2
Screenshot 3
Kingdom 7 appears in the list but brings me back to Kingdom 1 if I click it as Team 2 Faction (although it works as Team 1 Faction: Screenshot 4)


*And if I swap Kingdom 6 and Kingdom 7 in module_factions, the game allows me to choose Kingdom 7 as Team 2 Faction but not Kingdom 6 anymore (Screenshot 5 and Screenshot 6)
 
Last edited:
Can you add five factions to your mod and report me which faction gets always chosen when you select them? You reported before that Swadia/Vaegir got chosen instead of faction 7 and 8 and that faction 9 worked normally.
Did you also make any other changes to your module or is this your start at modding here? Like did you edit any presentations, scripts, etc.?
Ah, and is it not working at all game modes or only at specific ones?
 
Last edited:
I have already worked on my module by doing changes to both singleplayer and multiplayer, but nothing related to this (mainly in dialogs and game_menus, and a few scripts for adding new equipment to multiplayer - and these work perfectly)

The issue appears with all multiplayer game modes. After adding Factions #7, #8, #9, #10, and #11 this is what happens:
- All of them work normally as Team 1 Faction,
- When selecting Faction #7* as Team 2 Faction, it brings me back to Faction #1 (→ Swadia)
- When selecting Faction #8* as Team 2 Faction, it brings me back to Faction #2 (→ Vaegir)
- When selecting Factions #9, #10, and #11 as Team 2 Faction, it works

*More generally speaking, this happens when I select the 7th and 8th factions in the list - whether they are #7 and #8 or not
 
Last edited:
Strange behaviour, I would have predicted some other outcome now. If you are ingame, you also can't poll for the factions 7 and 8, can you?

Can you upload your module_factions, module_presentations and module_scripts as well as module_constants? Then I would take a look tomorrow if I find something strange. Won't manage it this evening anymore. I will then also try it myself with a clean Native module system and test it for that, I can't recall something like that happening at my last module.
 
Thanks a lot for your help, here's a link with the files: Dropbox
Submitting a poll for these factions actually works.. I can play with factions #7 and #8 but if I come back to the main menu and try to select them from there I won't be able to choose them anymore
 
I think I have found the problem, can't compile at the moment so you would need to test it by yourself. But I am confident that it is this snippet since it would also explain that only the factions 7 and 8 are affected.
Go to module_presentations.py and there to line 2822. You will see this snippet here:
Code:
        (eq, ":object", "$g_presentation_obj_admin_panel_12"),
        #INVASION MODE START
        (try_begin),
          (eq, ":value", 6),
          (assign, "$g_multiplayer_next_team_2_faction", "fac_outlaws"),
        (else_try),
          (eq, ":value", 7),
          (assign, "$g_multiplayer_next_team_2_faction", "fac_ccoop_all_stars"),
        (else_try),
          (store_add, "$g_multiplayer_next_team_2_faction", ":value", npc_kingdoms_begin),
        (try_end),
        #INVASION MODE END
##        (try_begin),
##          (ge, "$g_multiplayer_next_team_2_faction", "$g_multiplayer_next_team_1_faction"),
##          (val_add, "$g_multiplayer_next_team_2_faction", 1),
##        (try_end),
        (multiplayer_send_2_int_to_server, multiplayer_event_admin_set_team_faction, 2, "$g_multiplayer_next_team_2_faction"),
        (presentation_set_duration, 0),
        (start_presentation, "prsnt_game_multiplayer_admin_panel"),
The part between #INVASION MODE START and #INVASION MODE END has been added to Native when they included the new Coop modus to the multiplayer which has been after the tutorial here has been written. It adds two new factions to the selection menu which aren't within the range kingdoms_begin and kingdoms_end, so a neat way to add in additional options.
I also didn't notice it myself at my own module since I removed all newly added stuff beforehand since I wanted to rewrite it by myself. You have now two options out of which you can choose your solution:
1) You can remove it, replacing that snippet above with following:
Code:
                (eq, ":object", "$g_presentation_obj_admin_panel_12"),
                (try_begin),
                    (store_add, "$g_multiplayer_next_team_2_faction", ":value", npc_kingdoms_begin),
                (try_end),
                (multiplayer_send_2_int_to_server, multiplayer_event_admin_set_team_faction, 2, "$g_multiplayer_next_team_2_faction"),
                (presentation_set_duration, 0),
                (start_presentation, "prsnt_game_multiplayer_admin_panel"),
2) If you want to keep those two optional factions you can simply count them up. So if you have normally ten additionally factions the fac_outlaws and fac_ccoop_all_stars (or whichever factions you want to be there) would be the factions 11 and 12 and the code snippet above would look like this:
Code:
        (eq, ":object", "$g_presentation_obj_admin_panel_12"),
        #INVASION MODE START
        (try_begin),
          (eq, ":value", 10),
          (assign, "$g_multiplayer_next_team_2_faction", "fac_outlaws"),
        (else_try),
          (eq, ":value", 11),
          (assign, "$g_multiplayer_next_team_2_faction", "fac_ccoop_all_stars"),
        (else_try),
          (store_add, "$g_multiplayer_next_team_2_faction", ":value", npc_kingdoms_begin),
        (try_end),
        #INVASION MODE END
##        (try_begin),
##          (ge, "$g_multiplayer_next_team_2_faction", "$g_multiplayer_next_team_1_faction"),
##          (val_add, "$g_multiplayer_next_team_2_faction", 1),
##        (try_end),
        (multiplayer_send_2_int_to_server, multiplayer_event_admin_set_team_faction, 2, "$g_multiplayer_next_team_2_faction"),
        (presentation_set_duration, 0),
        (start_presentation, "prsnt_game_multiplayer_admin_panel"),

Go with whichever option you prefer here. Additionally you need to change it in the same style (removing it vs. editing the numbers) at module_scripts.py. Go here to the script script_multiplayer_fill_available_factions_combo_button. You see these lines here:
Code:
     #INVASION MODE START
     (try_begin),
       (eq, "$g_multiplayer_game_type", multiplayer_game_type_captain_coop),
       (eq, ":overlay_id", "$g_presentation_obj_admin_panel_12"),
       (str_store_faction_name, s0, "fac_outlaws"),
       (overlay_add_item, ":overlay_id", s0),
       (str_store_faction_name, s0, "fac_ccoop_all_stars"),
       (overlay_add_item, ":overlay_id", s0),
       (try_begin),
         (eq, ":selected_faction_no", "fac_outlaws"),
         (overlay_set_val, ":overlay_id", 6),
       (else_try),
         (eq, ":selected_faction_no", "fac_ccoop_all_stars"),
         (overlay_set_val, ":overlay_id", 7),
       (else_try),
         (val_sub, ":selected_faction_no", "fac_kingdom_1"),
         (overlay_set_val, ":overlay_id", ":selected_faction_no"),
       (try_end),
     (else_try),
       (try_begin),
         (gt, ":selected_faction_no", kingdoms_end),
         (overlay_set_val, ":overlay_id", 1),
       (else_try),
         (val_sub, ":selected_faction_no", "fac_kingdom_1"),
         (overlay_set_val, ":overlay_id", ":selected_faction_no"),
       (try_end),
     (try_end),
     #INVASION MODE END
Even though the critical part gets only triggered in the Coop Modus you want to adapt it there too. Edit the numbers to be the same as before or edit that snippet to the following:
Code:
     (try_begin),
        (gt, ":selected_faction_no", kingdoms_end),
        (overlay_set_val, ":overlay_id", 1),
      (else_try),
        (val_sub, ":selected_faction_no", "fac_kingdom_1"),
        (overlay_set_val, ":overlay_id", ":selected_faction_no"),
     (try_end),

And no worries, nearly everyone would have fallen for that bug, you are only the first one to write here after six years. I would also have stumbled above it if I wouldn't have coincidentally removed those lines by default. It's actually nice that you got that bug since I understood now better a code snippet myself of which I can make use of :lol:
 
Last edited:
Back
Top Bottom