From 11e33d7ec3059ccf1022cf8f369631f1e5aaedd7 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sat, 22 Apr 2023 20:12:46 -0700 Subject: [PATCH] Encounter: add better team randomization between games --- scripts/zm/replaced/_globallogic_ui.gsc | 31 +++++++--------- scripts/zm/zgrief/zgrief_reimagined.gsc | 49 ++++++++++++++++++------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/scripts/zm/replaced/_globallogic_ui.gsc b/scripts/zm/replaced/_globallogic_ui.gsc index fe682dba..268b5dcf 100644 --- a/scripts/zm/replaced/_globallogic_ui.gsc +++ b/scripts/zm/replaced/_globallogic_ui.gsc @@ -58,31 +58,28 @@ menuautoassign( comingfrommenu ) { if ( sessionmodeiszombiesgame() ) { - if (level.allow_teamchange) + if (assignment == "") { - if (assignment == "") + guids = strTok(getDvar("team_axis"), " "); + foreach (guid in guids) { - guids = strTok(getDvar("team_axis"), " "); - foreach (guid in guids) + if (self getguid() == int(guid)) { - if (self getguid() == int(guid)) - { - assignment = "axis"; - break; - } + assignment = "axis"; + break; } } + } - if (assignment == "") + if (assignment == "") + { + guids = strTok(getDvar("team_allies"), " "); + foreach (guid in guids) { - guids = strTok(getDvar("team_allies"), " "); - foreach (guid in guids) + if (self getguid() == int(guid)) { - if (self getguid() == int(guid)) - { - assignment = "allies"; - break; - } + assignment = "allies"; + break; } } } diff --git a/scripts/zm/zgrief/zgrief_reimagined.gsc b/scripts/zm/zgrief/zgrief_reimagined.gsc index c2465ec7..deb802b9 100644 --- a/scripts/zm/zgrief/zgrief_reimagined.gsc +++ b/scripts/zm/zgrief/zgrief_reimagined.gsc @@ -1144,6 +1144,9 @@ round_start_wait(time, initial) level thread freeze_hotjoin_players(); flag_wait("initial_blackscreen_passed"); + + setDvar("team_axis", ""); + setDvar("team_allies", ""); } else { @@ -2552,23 +2555,41 @@ save_teams_on_intermission() { level waittill("intermission"); - text = ""; - players = get_players("axis"); - foreach (player in players) + axis_guids = ""; + allies_guids = ""; + + if (level.allow_teamchange) { - text += player getguid() + " "; + players = get_players("axis"); + foreach (player in players) + { + axis_guids += player getguid() + " "; + } + + players = get_players("allies"); + foreach (player in players) + { + allies_guids += player getguid() + " "; + } + } + else + { + players = array_randomize(get_players()); + for (i = 0; i < players.size; i++) + { + if (i % 2 == 0) + { + axis_guids += player getguid() + " "; + } + else + { + allies_guids += player getguid() + " "; + } + } } - setDvar("team_axis", text); - - text = ""; - players = get_players("allies"); - foreach (player in players) - { - text += player getguid() + " "; - } - - setDvar("team_allies", text); + setDvar("team_axis", axis_guids); + setDvar("team_allies", allies_guids); } all_voice_on_intermission()