private static void SendMatchState(int connectionId) { if (NetworkMatch.IsTeamMode(NetworkMatch.GetMode())) { foreach (var team in MPTeams.ActiveTeams) { NetworkServer.SendToClient(connectionId, CustomMsgType.SetScoreForTeam, new ScoreForTeamMessage { team = (int)team, score = NetworkMatch.m_team_scores[(int)team] }); } } //if (!MPTweaks.ClientHasMod(connectionId)) // return; var n = Overload.NetworkManager.m_Players.Count; var msg = new MatchStateMessage() { m_match_elapsed_seconds = NetworkMatch.m_match_elapsed_seconds, m_player_states = new PlayerMatchState[n] }; int i = 0; foreach (var player in Overload.NetworkManager.m_Players) { msg.m_player_states[i++] = new PlayerMatchState() { m_net_id = player.netId, m_kills = player.m_kills, m_deaths = player.m_deaths, m_assists = player.m_assists } } ; NetworkServer.SendToClient(connectionId, ModCustomMsg.MsgSetMatchState, msg); }
static bool Prefix(UIElement __instance, Vector2 pos) { if (!MenuManager.mp_display_player_list || ((!NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) || MPTeams.NetworkMatchTeamCount == 2))) // && //NetworkMatch.GetMaxPlayersForMatch() <= 8)) { return(true); } MPTeams.DrawLobby(__instance, pos); return(false); }
static void Postfix(UIElement __instance) { if (MenuManager.m_menu_micro_state != 2 || !NetworkMatch.IsTeamMode(MenuManager.mms_mode)) { return; } Vector2 position = Vector2.zero; position.y = -279f + 62f * 6; __instance.SelectAndDrawStringOptionItem("TEAM COUNT", position, 8, MPTeams.MenuManagerTeamCount.ToString(), string.Empty, 1.5f, MenuManager.mms_mode == MatchMode.ANARCHY || !MenuManager.m_mp_lan_match); }
static bool Prefix(UIElement __instance) { if (!NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) || (MPTeams.NetworkMatchTeamCount == 2 && NetworkMatch.m_players.Count <= 8)) { return(true); } if (GameManager.m_local_player.m_hitpoints < 0f) { MPTeams.DrawPostgame(__instance); } return(false); }
static bool Prefix(ref MpTeam __result, int connection_id) { if (!NetworkMatch.IsTeamMode(NetworkMatch.GetMode())) { __result = MpTeam.ANARCHY; return(false); } if (NetworkMatch.GetMode() == MatchMode.ANARCHY || (MPTeams.NetworkMatchTeamCount == 2 && !MPJoinInProgress.NetworkMatchEnabled)) // use this simple balancing method for JIP to hopefully solve JIP team imbalances { return(true); } if (NetworkMatch.m_players.TryGetValue(connection_id, out var connPlayer)) // keep team if player already exists (when called from OnUpdateGameSession) { __result = connPlayer.m_team; return(false); } int[] team_counts = new int[(int)MPTeams.MPTEAM_NUM]; foreach (var player in NetworkMatch.m_players.Values) { team_counts[(int)player.m_team]++; } MpTeam min_team = MpTeam.TEAM0; foreach (var team in MPTeams.Teams) { if (team_counts[(int)team] < team_counts[(int)min_team] || (team_counts[(int)team] == team_counts[(int)min_team] && NetworkMatch.m_team_scores[(int)team] < NetworkMatch.m_team_scores[(int)min_team])) { min_team = team; } } __result = min_team; Debug.LogFormat("GetTeamForPlayer: result {0}, conn {1}, counts {2}, scores {3}", (int)min_team, connection_id, team_counts.Join(), NetworkMatch.m_team_scores.Join()); return(false); }
static void Postfix(PrivateMatchDataMessage __result) { Debug.Log("Build PMD name jipsingle " + MPJoinInProgress.SingleMatchEnable); if ((MPTeams.MenuManagerTeamCount > 2 || MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable || RearView.MPMenuManagerEnabled || MPSuddenDeath.SuddenDeathMenuEnabled) && MenuManager.m_mp_lan_match) { __result.m_name += new string(new char[] { '\0', (char)( ((Math.Max(2, MPTeams.MenuManagerTeamCount) - 2) & 7) | (MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable ? 8 : 0) | (RearView.MPMenuManagerEnabled ? 16 : 0) | (MPSuddenDeath.SuddenDeathMenuEnabled ? 32 : 0)) }); } Debug.Log("Build PMD name " + String.Join(",", __result.m_name.Select(x => ((int)x).ToString()).ToArray())); if (MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable || (MenuManager.m_mp_lan_match && MPInternet.Enabled)) { __result.m_num_players_to_start = 1; } if ((int)__result.m_match_mode > (int)ExtMatchMode.CTF) // newer matchmodes are sent with ModPrivateData { __result.m_match_mode = NetworkMatch.IsTeamMode(__result.m_match_mode) ? MatchMode.TEAM_ANARCHY : MatchMode.ANARCHY; } }
public static bool MatchNeedsMod() { return((int)NetworkMatch.GetMode() > (int)MatchMode.TEAM_ANARCHY || (NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) && MPTeams.NetworkMatchTeamCount > 2)); }
static void DrawDeathSummary(UIElement uie) { Vector2 pos; if (MPDeathReview.stickyDeathReview) { pos = new Vector2(UIManager.UI_LEFT + 160f, UIManager.UI_TOP + 250f); } else { pos = new Vector2((UIManager.UI_LEFT + UIManager.UI_RIGHT) / 2f, UIManager.UI_TOP + 180f); } var killer = Overload.NetworkManager.m_Players.FirstOrDefault(x => x.netId == MPDeathReview.lastDeathReview.m_killer_id); var assister = Overload.NetworkManager.m_Players.FirstOrDefault(x => x.netId == MPDeathReview.lastDeathReview.m_assister_id); var c = UIManager.m_col_red; var alpha_mod = 1f; var w = 120f; if ((!MPDeathReview.stickyDeathReview || MPDeathReview.showDeathReviewDetails) && killer && killer != GameManager.m_local_player) { UIManager.DrawQuadBarHorizontal(pos - Vector2.down * 24f, 103f, 36f, 36f, 0.3f * UIManager.m_col_black, 199); c = NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) ? MPTeams.TeamColor(killer.m_mp_team, 0) : UIManager.m_col_red; var damages = MPDeathReview.lastDeathReview.players.FirstOrDefault(x => x.Key == killer.netId).Value; DrawHeader(uie, pos, $"KILLER: {killer.m_mp_name}", $"[{(damages.Sum(x => x.damage) / MPDeathReview.lastDeathReview.players.SelectMany(x => x.Value).Sum(x => x.damage)):P0}]", w, c, 0.35f); pos.y += 32f; DrawDamageSummary(uie, pos, c, 0.45f, alpha_mod, damages); pos.y += 40f; } if (MPDeathReview.showDeathReviewDetails && assister != null && assister.netId != killer.netId) { UIManager.DrawQuadBarHorizontal(pos - Vector2.down * 24f, 103f, 36f, 36f, 0.3f * UIManager.m_col_black, 199); c = NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) ? MPTeams.TeamColor(assister.m_mp_team, 0) : UIManager.m_col_white; var damages = MPDeathReview.lastDeathReview.players.FirstOrDefault(x => x.Key == assister.netId).Value; DrawHeader(uie, pos, $"ASSIST: {assister.m_mp_name}", $"[{(damages.Sum(x => x.damage) / MPDeathReview.lastDeathReview.players.SelectMany(x => x.Value).Sum(x => x.damage)):P0}]", w, c, 0.35f); pos.y += 32f; DrawDamageSummary(uie, pos, c, 0.45f, alpha_mod, damages); pos.y += 40f; } // Other enemy damage not contributed by killer/assister var otherIds = Overload.NetworkManager.m_Players.Where(x => x.netId != GameManager.m_local_player.netId && x != killer && x != assister && (x.m_mp_team == MpTeam.ANARCHY || x.m_mp_team != GameManager.m_local_player.m_mp_team)).Select(x => x.netId); if (MPDeathReview.showDeathReviewDetails && MPDeathReview.lastDeathReview.players.Any(x => otherIds.Contains(x.Key))) { UIManager.DrawQuadBarHorizontal(pos - Vector2.down * 24f, 103f, 36f, 36f, 0.3f * UIManager.m_col_black, 199); var otherDamages = MPDeathReview.lastDeathReview.players.Where(x => otherIds.Contains(x.Key)).SelectMany(x => x.Value); c = NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) ? MPTeams.TeamColor(GameManager.m_local_player.m_mp_team, 0) : UIManager.m_col_white; DrawHeader(uie, pos, "OTHER", $"[{(otherDamages.Sum(x => x.damage) / MPDeathReview.lastDeathReview.players.SelectMany(x => x.Value).Sum(x => x.damage)):P0}]", w, c, 0.35f); pos.y += 32f; DrawDamageSummary(uie, pos, c, 0.45f, alpha_mod, otherDamages); pos.y += 40f; } // Self and misc damage var selfIds = Overload.NetworkManager.m_Players.Where(x => x.netId == GameManager.m_local_player.netId || (NetworkMatch.GetMode() == MatchMode.TEAM_ANARCHY && x.m_mp_team == GameManager.m_local_player.m_mp_team)).Select(x => x.netId); if ((MPDeathReview.showDeathReviewDetails || killer == GameManager.m_local_player && !MPDeathReview.stickyDeathReview) && MPDeathReview.lastDeathReview.players.Any(x => selfIds.Contains(x.Key))) { UIManager.DrawQuadBarHorizontal(pos - Vector2.down * 24f, 103f, 36f, 36f, 0.3f * UIManager.m_col_black, 199); var selfDamages = MPDeathReview.lastDeathReview.players.Where(x => selfIds.Contains(x.Key)).SelectMany(x => x.Value); c = NetworkMatch.IsTeamMode(NetworkMatch.GetMode()) ? MPTeams.TeamColor(GameManager.m_local_player.m_mp_team, 0) : UIManager.m_col_white; DrawHeader(uie, pos, "SELF/MISC", $"[{(selfDamages.Sum(x => x.damage) / MPDeathReview.lastDeathReview.players.SelectMany(x => x.Value).Sum(x => x.damage)):P0}]", w, c, 0.35f); pos.y += 32f; DrawDamageSummary(uie, pos, c, 0.45f, alpha_mod, selfDamages); pos.y += 40f; } if (MPDeathReview.stickyDeathReview || (!MPDeathReview.showDeathReviewDetails && ((assister != null && assister.netId != killer.netId) || MPDeathReview.lastDeathReview.players.Any(x => otherIds.Contains(x.Key)) || (killer != GameManager.m_local_player && MPDeathReview.lastDeathReview.players.Any(x => selfIds.Contains(x.Key)))))) { if (MPDeathReview.stickyDeathReview && !MPDeathReview.showDeathReviewDetails) { pos.y = 100f; } uie.DrawStringSmall(ScriptTutorialMessage.ControlString(CCInput.USE_BOOST) + " - SHOW MORE DETAILS", pos + Vector2.down * 18f, 0.3f, StringOffset.CENTER, UIManager.m_col_ui5 * 0.7f, alpha_mod, -1f); } }
private static void SendMatchState(int connectionId) { if (NetworkMatch.IsTeamMode(NetworkMatch.GetMode())) { foreach (var team in MPTeams.ActiveTeams) { NetworkServer.SendToClient(connectionId, CustomMsgType.SetScoreForTeam, new ScoreForTeamMessage { team = (int)team, score = NetworkMatch.m_team_scores[(int)team] }); } } //if (!MPTweaks.ClientHasMod(connectionId)) // return; // Process any disconnected scoreboard entries, add them to active pilot, and remove stale scoreboard objects foreach (var player in Overload.NetworkManager.m_Players) { // Add any previous records for pilot on join var playersSameName = Overload.NetworkManager.m_PlayersForScoreboard.Where(x => !String.IsNullOrEmpty(x.m_mp_name) && x.m_mp_name == player.m_mp_name).ToList(); player.m_kills = playersSameName.Sum(x => x.m_kills); player.m_deaths = playersSameName.Sum(x => x.m_deaths); player.m_assists = playersSameName.Sum(x => x.m_assists); // Remove previously DC'd players of same name from server scoreboard list playersSameName.Where(x => x != player).ToList().ForEach(x => Overload.NetworkManager.m_PlayersForScoreboard.Remove(x)); } var n = Overload.NetworkManager.m_Players.Count; var msg = new MatchStateMessage() { m_match_elapsed_seconds = NetworkMatch.m_match_elapsed_seconds, m_player_states = new PlayerMatchState[n] }; int i = 0; foreach (var player in Overload.NetworkManager.m_Players) { msg.m_player_states[i++] = new PlayerMatchState() { m_net_id = player.netId, m_kills = player.m_kills, m_deaths = player.m_deaths, m_assists = player.m_assists } } ; NetworkServer.SendToClient(connectionId, MessageTypes.MsgSetMatchState, msg); // Send disconnected pilot stats as separate message if (MPTweaks.ClientHasTweak(connectionId, "jip")) { var dcPlayers = Overload.NetworkManager.m_PlayersForScoreboard.Where(x => !Overload.NetworkManager.m_Players.Contains(x)); var dcmsg = new DisconnectedPlayerMatchStateMessage() { m_player_states = new DisconnectedPlayerMatchState[dcPlayers.Count()] }; int j = 0; foreach (var player in dcPlayers) { dcmsg.m_player_states[j++] = new DisconnectedPlayerMatchState() { m_net_id = NetworkInstanceId.Invalid, m_kills = player.m_kills, m_deaths = player.m_deaths, m_assists = player.m_assists, m_mp_name = player.m_mp_name, m_mp_team = player.m_mp_team }; } NetworkServer.SendToClient(connectionId, MessageTypes.MsgSetDisconnectedMatchState, dcmsg); } }