WB Coding Disabling a multiplayer game type

正在查看此主题的用户

John25-

Sergeant at Arms
I am trying to disable "Invasion" multiplayer game type in my mod, but without deleting all the coding that is related to it in the module system. Is there a way to simply disable the option when selecting a game type? It can be done for factions by putting them after "kingdoms_end" in module_factions.py, maybe it works for game types as well
 
解决方案
Should it be done in module_presentations.py?
Of course it is there, I mentioned that it's a presentation :razz:
I have found these two multiplayer_game_type_names_begin and multiplayer_num_game_types, but I have no idea of what to do with them as they only appear once - in this piece of coding:
A constant never only appears once, it might get initiated at another file. Use Notepad++ when working with the MS since it can also search inside other files in the same folder for crossreferences. multiplayer_num_game_types for example gets initiated in header_common. As a beginner you should in general never edit something in a header file until you are sure you know what you are doing or some tutorial/OSP code is...
The easiest would probably to prevent it from showing up at the admin tools, so look for the presentation game_multiplayer_admin_panel. multiplayer_game_type_names_begin and multiplayer_num_game_types might be what you should look for, perhaps reducing the latter variable by 1 (given that the Invasion mode is the latest multiplayer game mode) could perhaps already suffice.
 
点赞 0
Should it be done in module_presentations.py? I have found these two multiplayer_game_type_names_begin and multiplayer_num_game_types, but I have no idea of what to do with them as they only appear once - in this piece of coding:

(try_begin),
(eq, "$g_multiplayer_changing_game_type_allowed", 1),
(create_combo_button_overlay, "$g_presentation_obj_admin_panel_10"),
(position_set_x, pos1, 800),
(position_set_y, pos1, 800),
(overlay_set_size, "$g_presentation_obj_admin_panel_10", pos1),
(position_set_x, pos1, 490),
(position_set_y, pos1, ":cur_y"),
(overlay_set_position, "$g_presentation_obj_admin_panel_10", pos1),
(try_for_range, ":i_game_type", 0, multiplayer_num_game_types),
(store_add, ":string_index", ":i_game_type", multiplayer_game_type_names_begin),
(str_store_string, s0, ":string_index"),
(overlay_add_item, "$g_presentation_obj_admin_panel_10", s0),
(try_end),
(overlay_set_val, "$g_presentation_obj_admin_panel_10", "$g_multiplayer_game_type"),
(else_try),
(assign, "$g_presentation_obj_admin_panel_10", -1),
(store_add, ":string_index", "$g_multiplayer_game_type", multiplayer_game_type_names_begin),
(str_store_string, s0, ":string_index"),
(create_text_overlay, reg0, s0, 0),
(position_set_x, pos1, 385),
(position_set_y, pos1, ":cur_y"),
(overlay_set_position, reg0, pos1),
(try_end),
 
点赞 0
Should it be done in module_presentations.py?
Of course it is there, I mentioned that it's a presentation :razz:
I have found these two multiplayer_game_type_names_begin and multiplayer_num_game_types, but I have no idea of what to do with them as they only appear once - in this piece of coding:
A constant never only appears once, it might get initiated at another file. Use Notepad++ when working with the MS since it can also search inside other files in the same folder for crossreferences. multiplayer_num_game_types for example gets initiated in header_common. As a beginner you should in general never edit something in a header file until you are sure you know what you are doing or some tutorial/OSP code is telling you to do specific stuff there. For your case it might however be the solution. So you need to be able to read the code snippet which you put above (use btw rather a code than a quote environment). One more important rule: Use indentation! It makes it far easier to read the code and discover potential misstakes at your own code. Now the first try loop here tells you that (read the comments)
插入代码块:
      (try_begin), #if
        (eq, "$g_multiplayer_changing_game_type_allowed", 1), #it is allowed for admins to change the game mode
        (create_combo_button_overlay, "$g_presentation_obj_admin_panel_10"), #a new combo button overlay should be created
        (position_set_x, pos1, 800), #x-size
        (position_set_y, pos1, 800), #y-size (at presentations the ration x:y is sometimes the relevant thing but presentations are still far away for you)
        (overlay_set_size, "$g_presentation_obj_admin_panel_10", pos1), #give the button this size
        (position_set_x, pos1, 490), #x-coordinate (notice that the operation is the same as four lines before but getting initiated again, now for the position instead of the size
        (position_set_y, pos1, ":cur_y"), #y-coordinate, given by some predefined constant some lines up
        (overlay_set_position, "$g_presentation_obj_admin_panel_10", pos1), #set the position of the combo button
        (try_for_range, ":i_game_type", 0, multiplayer_num_game_types), #try for all game types, the number of them is multiplayer_num_game_types = 9
          (store_add, ":string_index", ":i_game_type", multiplayer_game_type_names_begin), #add for each try a string, starting from multiplayer_game_type_names_begin
          (str_store_string, s0, ":string_index"), #store the string in s0
          (overlay_add_item, "$g_presentation_obj_admin_panel_10", s0), #add an overlay item with that string
        (try_end), #repeat 9 times before continuing with the rest.
        (overlay_set_val, "$g_presentation_obj_admin_panel_10", "$g_multiplayer_game_type"), #assign global variable to this button
      (else_try),
... other not so important loop
      (try_end),
So it might be a good idea to just edit in header_common multiplayer_num_game_types = 9 to multiplayer_num_game_types = 8. That way it would do the loop only 8 times and would thus not name the last one which is the Invasion mode (sometimes called captain_coop). Try that and see if it works.
 
点赞 0
解决方案
I just have one more question: it worked because I tried to remove the last option in the list, but let's say someone reading this post wants to remove another option e.g. "Siege" or "Capture the flag". How can that be done?
 
点赞 0
插入代码块:
#multiplayer game type indices
multiplayer_game_type_deathmatch             = 0
multiplayer_game_type_team_deathmatch        = 1
multiplayer_game_type_battle                 = 2
multiplayer_game_type_destroy                = 3
multiplayer_game_type_capture_the_flag       = 4
multiplayer_game_type_headquarters           = 5
multiplayer_game_type_siege                  = 6
multiplayer_game_type_duel                   = 7
#INVASION MODE START
multiplayer_game_type_captain_coop           = 8
multiplayer_num_game_types                   = 9
#INVASION MODE END
Rearranging the order and repeating the above mentioned way would probably suffice for this.
 
点赞 0
It doesn't seem to work this way - I moved "Duel" up in the list and then changed multiplayer_num_game_types to 7, but that's the Duel game type that doesn't appear anymore.
I even changed the figures, like this:
插入代码块:
#multiplayer game type indices
multiplayer_game_type_deathmatch             = 0
multiplayer_game_type_team_deathmatch        = 1
multiplayer_game_type_battle                 = 2
multiplayer_game_type_duel                   = 3
multiplayer_game_type_destroy                = 4
multiplayer_game_type_capture_the_flag       = 5
multiplayer_game_type_headquarters           = 6
multiplayer_game_type_siege                  = 7

multiplayer_num_game_types                   = 7

But this is what happens in-game:
6AWwd1w.jpg
 
点赞 0
I think you can select it due to the line
插入代码块:
(store_add, ":string_index", ":i_game_type", multiplayer_game_type_names_begin),
which you have mentioned above but it could actually be another game type due to the sorting of the strings. Check for that (is it another game mode than the name says?) and if it is really mixed up, resort the strings as well and that should do it.
 
点赞 0
That's right, I looked at the names in the list but they were referring to another game type. It is also necessary to change their name in module_strings.py
Thanks again :smile:
 
点赞 0
后退
顶部 底部