Troop/Class Limits
Contents |
Troop Limits for Multiplayer
Coded by: Jerkuh
Python Files Used: Module_Scripts.py, Module_Presentations.py and Module_Common.py
How to implement:
1. Add All of the required New and Changed Codes (seen below) and make any edits said
2. Edit the units to your requirements:
(troop_set_slot, "trp_TROOPNAME", 300, PERCENTAGE OF TEAM), If you want the unit to be availabe to everyone put -2 at 'PERCENTAGE OF TEAM' If you want the unit to be availabe to only 1 person put -1 at 'PERCENTAGE OF TEAM'
3. Test the in-game admin panel
4. Change the ' (assign, ":cur_y", 1840), # This variable makes the size of the scroller screen, if you have more troops than fit you can change this value to somewhat higher.' to a higher or lower number for less or more scroll space.
New and Changed Codes:
Module_Scripts
Add these scripts
("player_troop_count", [ (assign, "$g_vikingr_team_1_count", 0), (assign, "$g_vikingr_team_2_count", 0), (try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"), (troop_set_slot, ":cur_troop", 301, 0), (try_end), (get_max_players, ":num_players"), (try_for_range, ":cur_player", 0, ":num_players"), (player_is_active, ":cur_player"), (player_get_troop_id, ":cur_troop", ":cur_player"), (neq, ":cur_troop", -1), (troop_get_slot, ":num", ":cur_troop", 301), (val_add, ":num", 1), (troop_set_slot, ":cur_troop", 301, ":num"), (player_get_team_no, ":cur_team", ":cur_player"), (troop_get_slot, ":max_troop", ":cur_troop", 300), (try_begin), (eq, ":cur_team", 0), (neq, ":max_troop", -1), (val_add, "$g_vikingr_team_1_count", 1), (else_try), (eq, ":cur_team", 1), (neq, ":max_troop", -1), (val_add, "$g_vikingr_team_2_count", 1), (try_end), (assign, reg1, ":cur_player"), #(display_message, "@Player ID: {reg1}"), (try_end), ]), ("cf_troop_room", [ (store_script_param, ":player_no", 1), (store_script_param, ":troop", 2), (assign, ":max", 0), (call_script, "script_player_troop_count"), (troop_get_slot, ":max_troop", ":troop", 300), (try_begin), (neq, ":max_troop", -1), (neq, ":max_troop", -2), (store_troop_faction, ":faction", ":troop"), (assign, ":max_faction", 0), (try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"), (troop_get_slot, ":max_cur", ":cur_troop", 300), (neq, ":max_cur", -1), (store_troop_faction, ":cur_faction", ":cur_troop"), (eq, ":faction", ":cur_faction"), (val_add, ":max_faction", ":max_cur"), (assign, reg1, ":max_cur"), #(display_message, "@Troop Perc: {reg1}"), (try_end), (val_mul, ":max_troop", 100), (assign, reg1, ":max_faction"), #(display_message, "@Maximum Count Of Faction: {reg1}"), (assign, reg1, ":max_troop"), #(display_message, "@Maximum Count Of Troops: {reg1}"), (store_div, ":max", ":max_troop", ":max_faction"), (assign, reg1, ":max"), #(display_message, "@Maximum Count Of Troops After Divide: {reg1}"), (player_get_team_no, ":cur_team", ":player_no"), (try_begin), (eq, ":cur_team", 0), (val_mul, ":max", "$g_vikingr_team_1_count"), (else_try), (eq, ":cur_team", 1), (val_mul, ":max", "$g_vikingr_team_2_count"), (try_end), (troop_get_slot, ":troop_amount", ":troop", 301), (val_mul, ":troop_amount", 100), (val_sub, ":max", ":troop_amount"), (val_add, ":max", 100), (val_div, ":max", 100), (else_try), (troop_get_slot, ":leader", ":troop", 301), (eq, ":leader", 0), (assign, ":max", 1), (else_try), (eq, ":max_troop", -2), (assign, ":max", 1), (try_end), (assign, reg1, ":max"), #(display_message, "@Maximum Count: {reg1}"), (gt, ":max", 0), ]), ("troop_limit_variables", [ # CHANGE ONLY THIS VARIABLES TO SET THE TROOP LIMIT PERCENTAGES (troop_set_slot, "trp_bueskytter_multiplayer", 300, 100), (troop_set_slot, "trp_hersir_multiplayer", 300, -2), (troop_set_slot, "trp_berserkr_multiplayer", 300, 80), (troop_set_slot, "trp_chieftain_multiplayer", 300, -1), # Leader (troop_set_slot, "trp_ceorl_multiplayer", 300, 100), (troop_set_slot, "trp_thegn_multiplayer", 300, -2), (troop_set_slot, "trp_huscarl_multiplayer", 300, 70), (troop_set_slot, "trp_earl_multiplayer", 300, -1), # Leader ]),
Change this
#script_game_quick_start # This script is called from the game engine for initializing the global variables for tutorial, multiplayer and custom battle modes. # INPUT: # none # OUTPUT: # none ("game_quick_start", [ #for quick battle mode (assign, "$g_is_quick_battle", 0), (assign, "$g_quick_battle_game_type", 0), (assign, "$g_quick_battle_troop", quick_battle_troops_begin), (assign, "$g_quick_battle_map", quick_battle_scenes_begin), (assign, "$g_quick_battle_team_1_faction", "fac_kingdom_1"), (assign, "$g_quick_battle_team_2_faction", "fac_kingdom_2"), (assign, "$g_quick_battle_army_1_size", 25), (assign, "$g_quick_battle_army_2_size", 25),
To
#script_game_quick_start # This script is called from the game engine for initializing the global variables for tutorial, multiplayer and custom battle modes. # INPUT: # none # OUTPUT: # none ("game_quick_start", [ (call_script, "script_troop_limit_variables"), #for quick battle mode (assign, "$g_is_quick_battle", 0), (assign, "$g_quick_battle_game_type", 0), (assign, "$g_quick_battle_troop", quick_battle_troops_begin), (assign, "$g_quick_battle_map", quick_battle_scenes_begin), (assign, "$g_quick_battle_team_1_faction", "fac_kingdom_1"), (assign, "$g_quick_battle_team_2_faction", "fac_kingdom_2"), (assign, "$g_quick_battle_army_1_size", 25), (assign, "$g_quick_battle_army_2_size", 25),
Change this
(else_try), (eq, ":event_type", multiplayer_event_change_troop_id), (store_script_param, ":value", 3), #troop-faction validity check (try_begin), (eq, ":value", -1), (player_set_troop_id, ":player_no", -1), (else_try), (is_between, ":value", multiplayer_troops_begin, multiplayer_troops_end), (player_get_team_no, ":player_team", ":player_no"), (is_between, ":player_team", 0, multi_team_spectator), (team_get_faction, ":team_faction", ":player_team"), (store_troop_faction, ":new_troop_faction", ":value"), (eq, ":new_troop_faction", ":team_faction"), (player_set_troop_id, ":player_no", ":value"), (call_script, "script_multiplayer_clear_player_selected_items", ":player_no"), (try_end),
To
(else_try), (eq, ":event_type", multiplayer_event_change_troop_id), (store_script_param, ":value", 3), #troop-faction validity check (try_begin), (eq, ":value", -1), (player_set_troop_id, ":player_no", -1), (else_try), (is_between, ":value", multiplayer_troops_begin, multiplayer_troops_end), (player_get_team_no, ":player_team", ":player_no"), (is_between, ":player_team", 0, multi_team_spectator), (team_get_faction, ":team_faction", ":player_team"), (store_troop_faction, ":new_troop_faction", ":value"), (eq, ":new_troop_faction", ":team_faction"), (call_script, "script_cf_troop_room", ":player_no", ":value"), (player_set_troop_id, ":player_no", ":value"), (call_script, "script_multiplayer_clear_player_selected_items", ":player_no"), (try_end),
Change this
(else_try), (eq, ":event_type", multiplayer_event_admin_set_disallow_ranged_weapons), (try_begin), (store_script_param, ":value", 3), #validity check (player_is_admin, ":player_no"), (is_between, ":value", 0, 2), #condition checks are done (assign, "$g_multiplayer_disallow_ranged_weapons", ":value"), (try_end), (else_try), ############### #CLIENT EVENTS# ###############
To
(else_try), (eq, ":event_type", multiplayer_event_admin_set_disallow_ranged_weapons), (try_begin), (store_script_param, ":value", 3), #validity check (player_is_admin, ":player_no"), (is_between, ":value", 0, 2), #condition checks are done (assign, "$g_multiplayer_disallow_ranged_weapons", ":value"), (try_end), (else_try), (eq, ":event_type", multiplayer_event_admin_set_troop_perc), (player_is_admin, ":player_no"), (store_script_param,":cur_troop",3), (store_script_param,":value",4), (troop_set_slot, ":cur_troop", 300, ":value"), (get_max_players, ":num_players"), (try_for_range, ":cur_player", 1, ":num_players"), (player_is_active, ":cur_player"), (multiplayer_send_2_int_to_player, ":cur_player", multiplayer_event_set_limitations, ":cur_troop", ":value"), (try_end), (else_try), ############### #CLIENT EVENTS# ###############
Change this
(else_try), (eq, ":event_type", multiplayer_event_cancel_duel), (store_script_param, ":value", 3), (try_begin), (agent_is_active, ":value"), (agent_get_player_id, ":value_player_no", ":value"), (try_begin), (player_is_active, ":value_player_no"), (str_store_player_username, s0, ":value_player_no"), (else_try), (str_store_agent_name, s0, ":value"), (try_end), (display_message, "str_your_duel_with_s0_is_cancelled"), (try_end), (try_begin), (get_player_agent_no, ":player_agent"), (agent_is_active, ":player_agent"), (agent_set_slot, ":player_agent", slot_agent_in_duel_with, -1), (agent_clear_relations_with_agents, ":player_agent"), (try_end), (else_try), (eq, ":event_type", multiplayer_event_show_server_message), (display_message, "str_server_s0", 0xFFFF6666), (try_end), ]),
To
(else_try), (eq, ":event_type", multiplayer_event_cancel_duel), (store_script_param, ":value", 3), (try_begin), (agent_is_active, ":value"), (agent_get_player_id, ":value_player_no", ":value"), (try_begin), (player_is_active, ":value_player_no"), (str_store_player_username, s0, ":value_player_no"), (else_try), (str_store_agent_name, s0, ":value"), (try_end), (display_message, "str_your_duel_with_s0_is_cancelled"), (try_end), (try_begin), (get_player_agent_no, ":player_agent"), (agent_is_active, ":player_agent"), (agent_set_slot, ":player_agent", slot_agent_in_duel_with, -1), (agent_clear_relations_with_agents, ":player_agent"), (try_end), (else_try), (eq, ":event_type", multiplayer_event_show_server_message), (display_message, "str_server_s0", 0xFFFF6666), (else_try), (eq, ":event_type", multiplayer_event_set_limitations), (store_script_param, ":troop", 3), (store_script_param, ":perc", 4), (troop_set_slot, ":troop", 300, ":perc"), (try_end), ]),
Change this
#script_multiplayer_send_initial_information # Input: arg1 = player_no # Output: none ("multiplayer_send_initial_information", [ (store_script_param, ":player_no", 1), (multiplayer_send_2_int_to_player, ":player_no", multiplayer_event_return_num_bots_in_team, 1, "$g_multiplayer_num_bots_team_1"), (multiplayer_send_2_int_to_player, ":player_no", multiplayer_event_return_num_bots_in_team, 2, "$g_multiplayer_num_bots_team_2"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_auto_team_balance_limit, "$g_multiplayer_auto_team_balance_limit"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_num_bots_voteable, "$g_multiplayer_num_bots_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_factions_voteable, "$g_multiplayer_factions_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_maps_voteable, "$g_multiplayer_maps_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_kick_voteable, "$g_multiplayer_kick_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_ban_voteable, "$g_multiplayer_ban_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_allow_player_banners, "$g_multiplayer_allow_player_banners"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_force_default_armor, "$g_multiplayer_force_default_armor"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_disallow_ranged_weapons, "$g_multiplayer_disallow_ranged_weapons"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_respawn_period, "$g_multiplayer_respawn_period"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_round_max_seconds, "$g_multiplayer_round_max_seconds"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_game_type, "$g_multiplayer_game_type"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_player_respawn_as_bot, "$g_multiplayer_player_respawn_as_bot"),
To
#script_multiplayer_send_initial_information # Input: arg1 = player_no # Output: none ("multiplayer_send_initial_information", [ (store_script_param, ":player_no", 1), (try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"), (troop_get_slot, ":cur_perc", ":cur_troop", 300), (multiplayer_send_2_int_to_player, ":player_no", multiplayer_event_set_limitations, ":cur_troop", ":cur_perc"), (try_end), (multiplayer_send_2_int_to_player, ":player_no", multiplayer_event_return_num_bots_in_team, 1, "$g_multiplayer_num_bots_team_1"), (multiplayer_send_2_int_to_player, ":player_no", multiplayer_event_return_num_bots_in_team, 2, "$g_multiplayer_num_bots_team_2"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_auto_team_balance_limit, "$g_multiplayer_auto_team_balance_limit"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_num_bots_voteable, "$g_multiplayer_num_bots_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_factions_voteable, "$g_multiplayer_factions_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_maps_voteable, "$g_multiplayer_maps_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_kick_voteable, "$g_multiplayer_kick_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_ban_voteable, "$g_multiplayer_ban_voteable"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_allow_player_banners, "$g_multiplayer_allow_player_banners"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_force_default_armor, "$g_multiplayer_force_default_armor"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_disallow_ranged_weapons, "$g_multiplayer_disallow_ranged_weapons"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_respawn_period, "$g_multiplayer_respawn_period"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_round_max_seconds, "$g_multiplayer_round_max_seconds"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_game_type, "$g_multiplayer_game_type"), (multiplayer_send_int_to_player, ":player_no", multiplayer_event_return_player_respawn_as_bot, "$g_multiplayer_player_respawn_as_bot"),
Module_Presentations
Change this
(assign, ":cur_troop_index", 0), (try_for_range, ":troop_no", multiplayer_troops_begin, multiplayer_troops_end), (store_troop_faction, ":troop_faction", ":troop_no"), (eq, ":troop_faction", ":my_faction_no"), (str_store_troop_name, s1, ":troop_no"), (create_button_overlay, reg0, s1, 0), (overlay_set_color, reg0, 0xFFFFFF), (store_add, ":button_index_slot", ":cur_troop_index", multi_data_troop_button_indices_begin), (troop_set_slot, "trp_multiplayer_data", ":button_index_slot", reg0), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (val_sub, ":cur_y", escape_menu_item_height), (position_set_y, pos1, ":cur_y"), (val_add, ":cur_troop_index", 1), (try_end), (presentation_set_duration, 999999), ]),
To
(assign, ":cur_troop_index", 0), (try_for_range, ":troop_no", multiplayer_troops_begin, multiplayer_troops_end), (store_troop_faction, ":troop_faction", ":troop_no"), (eq, ":troop_faction", ":my_faction_no"), (str_store_troop_name, s1, ":troop_no"), (create_button_overlay, reg0, s1, 0), (try_begin), (call_script, "script_cf_troop_room", ":my_player_no", ":troop_no"), (overlay_set_color, reg0, 0xFFFFFF), (overlay_set_hilight_color, reg0, 0x55FF50), (else_try), (overlay_set_color, reg0, 0x888888), (overlay_set_hilight_color, reg0, 0x888888), (try_end), (store_add, ":button_index_slot", ":cur_troop_index", multi_data_troop_button_indices_begin), (troop_set_slot, "trp_multiplayer_data", ":button_index_slot", reg0), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (val_sub, ":cur_y", escape_menu_item_height), (position_set_y, pos1, ":cur_y"), (val_add, ":cur_troop_index", 1), (try_end), (presentation_set_duration, 999999), ]),
Change this
(try_begin), (multiplayer_get_my_troop, ":troop_no"), (neq, ":troop_no", ":selected_troop_no"), (player_set_troop_id, ":my_player_no", ":selected_troop_no"), (multiplayer_send_int_to_server, multiplayer_event_change_troop_id, ":selected_troop_no"), (call_script, "script_multiplayer_set_default_item_selections_for_troop", ":selected_troop_no"), (call_script, "script_multiplayer_send_item_selections"), (try_end), (presentation_set_duration, 0), (assign, "$g_presentation_state", 0), (start_presentation, "prsnt_multiplayer_item_select"), (assign, ":end_cond", 0), #break (try_end), ]),
To
(try_begin), (multiplayer_get_my_troop, ":troop_no"), (neq, ":troop_no", ":selected_troop_no"), (call_script, "script_cf_troop_room", ":my_player_no", ":selected_troop_no"), (player_set_troop_id, ":my_player_no", ":selected_troop_no"), (multiplayer_send_int_to_server, multiplayer_event_change_troop_id, ":selected_troop_no"), (call_script, "script_multiplayer_set_default_item_selections_for_troop", ":selected_troop_no"), (call_script, "script_multiplayer_send_item_selections"), (assign, ":room", 1), (try_end), (try_begin), (eq,":room", 1), (presentation_set_duration, 0), (assign, "$g_presentation_state", 0), (start_presentation, "prsnt_multiplayer_item_select"), (assign, ":end_cond", 0), #break (else_try), (presentation_set_duration, 0), (start_presentation, "prsnt_multiplayer_troop_select"), (try_end), (try_end), ]),
Change this
(create_text_overlay, reg0, "str_force_default_armor", 0), (position_set_x, pos1, 30), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (create_check_box_overlay, "$g_presentation_obj_admin_panel_40", "mesh_checkbox_off", "mesh_checkbox_on"), (position_set_x, pos1, 7), (store_add, ":special_cur_y", ":cur_y", 7), (position_set_y, pos1, ":special_cur_y"), (overlay_set_position, "$g_presentation_obj_admin_panel_40", pos1), (overlay_set_val, "$g_presentation_obj_admin_panel_40", "$g_multiplayer_force_default_armor"), (set_container_overlay, -1),
To
(create_text_overlay, reg0, "str_force_default_armor", 0), (position_set_x, pos1, 30), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (create_check_box_overlay, "$g_presentation_obj_admin_panel_40", "mesh_checkbox_off", "mesh_checkbox_on"), (position_set_x, pos1, 7), (store_add, ":special_cur_y", ":cur_y", 7), (position_set_y, pos1, ":special_cur_y"), (overlay_set_position, "$g_presentation_obj_admin_panel_40", pos1), (overlay_set_val, "$g_presentation_obj_admin_panel_40", "$g_multiplayer_force_default_armor"), (assign, ":cur_troop_index", 0), (try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"), (troop_get_slot, ":max_cur", ":cur_troop", 300), (val_sub, ":cur_y", ":cur_y_adder"), (str_store_troop_name, s1, ":cur_troop"), (create_text_overlay, reg0, s1, 0), (position_set_x, pos1, 0), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (create_slider_overlay, reg0, 0, 100), (overlay_set_val, reg0, ":max_cur"), (store_add, ":button_index_slot", ":cur_troop_index", multi_data_troop_button_indices_begin), (troop_set_slot, "trp_multiplayer_data", ":button_index_slot", reg0), (troop_set_slot, ":cur_troop", 302, ":button_index_slot"), (position_set_x, pos1, 900), (position_set_y, pos1, 1000), (overlay_set_size, reg0, pos1), (position_set_x, pos1, 390), (position_set_y, pos1, ":cur_y"), (overlay_set_position, reg0, pos1), (val_add, ":cur_troop_index", 1), (try_end), (set_container_overlay, -1),
Change this
(else_try), (eq, ":object", "$g_presentation_obj_admin_panel_41"), (multiplayer_send_int_to_server, multiplayer_event_admin_set_anti_cheat, ":value"), (else_try), (eq, ":object", "$g_presentation_obj_admin_panel_42"), (multiplayer_send_int_to_server, multiplayer_event_admin_set_disallow_ranged_weapons, ":value"), (try_end), ]),
To
(else_try), (eq, ":object", "$g_presentation_obj_admin_panel_41"), (multiplayer_send_int_to_server, multiplayer_event_admin_set_anti_cheat, ":value"), (else_try), (eq, ":object", "$g_presentation_obj_admin_panel_42"), (multiplayer_send_int_to_server, multiplayer_event_admin_set_disallow_ranged_weapons, ":value"), (try_end), (assign, ":end_cond", multi_data_troop_button_indices_end), (try_for_range, ":i_button", multi_data_troop_button_indices_begin, ":end_cond"), (troop_slot_eq, "trp_multiplayer_data", ":i_button", ":object"), (try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"), (troop_slot_eq, ":cur_troop", 302, ":i_button"), (troop_set_slot, ":cur_troop", 300, ":value"), (multiplayer_send_2_int_to_server, multiplayer_event_admin_set_troop_perc, ":cur_troop", ":value"), (try_end), (try_end), ]),
Now you neet to change the troop trp_bueskytter_multiplayer in the first troop you use, in this operation.
(try_for_range, ":cur_troop", "trp_bueskytter_multiplayer", "trp_multiplayer_end"),
Change this
(create_mesh_overlay, reg0, "mesh_mp_ui_host_main"), (position_set_x, pos1, -1), (position_set_y, pos1, -1), (overlay_set_position, reg0, pos1), (position_set_x, pos1, 1002), (position_set_y, pos1, 1002), (overlay_set_size, reg0, pos1), (assign, ":cur_y", 1240), (assign, ":cur_y_adder", 40),
To
(create_mesh_overlay, reg0, "mesh_mp_ui_host_main"), (position_set_x, pos1, -1), (position_set_y, pos1, -1), (overlay_set_position, reg0, pos1), (position_set_x, pos1, 1002), (position_set_y, pos1, 1002), (overlay_set_size, reg0, pos1), (assign, ":cur_y", 1840), # This variable makes the size of the scroller screen, if you have more troops than fit you can change this value to somewhat higher. (assign, ":cur_y_adder", 40),
Module_Common
Add these lines
multiplayer_event_admin_set_troop_perc = 120 multiplayer_event_set_limitations = 121
Wolf.