Skip to content

Commit

Permalink
Changes Team Balance Responses for No-Commander Situations
Browse files Browse the repository at this point in the history
- When a player attempts to join a team for the first time AFTER the round (e.g., late joiners, etc.) has started then the mod now checks if the team has a commander or not
-- If the team does already have a commander then the player is swapped to another team to fix imbalance
-- If the team does not have a commander then the player's request is rejected and they have to re-select their choices
  • Loading branch information
data-bomb committed Dec 29, 2024
1 parent 2a96e57 commit 6728d9c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Si_BasicTeamBalance/Si_BasicTeamBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You should have received a copy of the GNU General Public License
using System.Linq;
using static MelonLoader.MelonLogger;

[assembly: MelonInfo(typeof(BasicTeamBalance), "Basic Team Balance", "1.4.1", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(BasicTeamBalance), "Basic Team Balance", "1.4.2", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

Expand Down Expand Up @@ -422,9 +422,26 @@ public static bool ProcessJoinTeam<T>(T gameModeInstance, GameByteStreamReader r
return false;
}

// if the player hasn't joined a team yet, force them to the team that needs it the most
// if the player hasn't joined a team yet
if (joiningPlayer.Team == null)
{
// check if the requested team doesn't have a commander yet, after a game start
if (gameModeInstance.GetCommanderForTeam(targetTeam) == null && GameMode.CurrentGameMode.GameOngoing)
{
// avoid chat spam
if (LastPlayerChatMessage != joiningPlayer)
{
HelperMethods.ReplyToCommand_Player(joiningPlayer, "'s switch was denied due to team imbalance");
LastPlayerChatMessage = joiningPlayer;
}

MelonLogger.Msg(joiningPlayer.PlayerName + "'s team switch was denied due to team imbalance");

SendClearRequest(playerSteam64, playerChannel);
return false;
}

// force them to the team that needs it the most
GameModeExt.ETeamsVersus versusMode = gameModeInstance.TeamsVersus;
Team? ForcedTeam = FindLowestPopulationTeam(gameModeInstance);
if (ForcedTeam != null)
Expand Down

0 comments on commit 6728d9c

Please sign in to comment.