Skip to content

Commit

Permalink
Adds Setting to Disable Removing Structures on Team Elimination
Browse files Browse the repository at this point in the history
- For the HQLessHumansLose mod, adds HQ_RemoveStructuresOnElimination preference for severs to decide whether to remove all structures when a team is eliminated in a 3-way game. Removing all structures is reported to cause significant 4+min AI delays due to the navmesh recalculations
  • Loading branch information
data-bomb committed Jun 16, 2024
1 parent b520933 commit d00e3d3
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions Si_HQlessHumansLose/Si_HQlessHumansLose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,27 @@ You should have received a copy of the GNU General Public License
using System;
using SilicaAdminMod;

[assembly: MelonInfo(typeof(HQlessHumansLose), "HQless Humans Lose", "1.3.6", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(HQlessHumansLose), "HQless Humans Lose", "1.3.7", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

namespace Si_HQlessHumansLose
{
public class HQlessHumansLose : MelonMod
{
static MelonPreferences_Category _modCategory = null!;
public static MelonPreferences_Entry<bool> Pref_HQ_RemoveStructuresOnElimination = null!;

static Team? losingTeam;
static Player? destroyerOfWorlds;
static float Timer_SendTeamLostMessage = HelperMethods.Timer_Inactive;

public override void OnInitializeMelon()
{
_modCategory ??= MelonPreferences.CreateCategory("Silica");
Pref_HQ_RemoveStructuresOnElimination ??= _modCategory.CreateEntry<bool>("HQ_RemoveStructuresOnElimination", false);
}

public static void TeamLostMessage(Team team)
{
Player broadcastPlayer = HelperMethods.FindBroadcastPlayer();
Expand Down Expand Up @@ -106,18 +115,21 @@ public static void EliminateTeam(Team team)
// are there still two remaining factions after this one is eliminated?
if (versusMode == MP_Strategy.ETeamsVersus.HUMANS_VS_HUMANS_VS_ALIENS && !OneFactionAlreadyEliminated())
{
// destroy structures
for (int i = 0; i < team.Structures.Count; i++)
// check if we should destroy all structures
if (Pref_HQ_RemoveStructuresOnElimination.Value)
{
// but don't destroy bunkers if there's still 2 teams left
if (team.Structures[i].ToString().StartsWith("Bunk"))
for (int i = 0; i < team.Structures.Count; i++)
{
continue;
}
// but don't destroy bunkers if there's still 2 teams left
if (team.Structures[i].ToString().StartsWith("Bunk"))
{
continue;
}

team.Structures[i].DamageManager.SetHealth01(0.0f);
team.Structures[i].DamageManager.SetHealth01(0.0f);
}
}

// destroy units (otherwise AI will roam around doing odd things)
DestroyAllUnits(team);
}
Expand Down

0 comments on commit d00e3d3

Please sign in to comment.