From 3c503dcb4c49f42e3772bd6890d0fc2f32759295 Mon Sep 17 00:00:00 2001 From: data-bomb Date: Thu, 15 Feb 2024 18:34:54 -0800 Subject: [PATCH] HQLessHumansLose Fixes - Pass result by reference to allow changes - Correctly detect 2-team situation in HvHvA --- Si_HQlessHumansLose/Si_HQlessHumansLose.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Si_HQlessHumansLose/Si_HQlessHumansLose.cs b/Si_HQlessHumansLose/Si_HQlessHumansLose.cs index f3da585..e65f0f0 100644 --- a/Si_HQlessHumansLose/Si_HQlessHumansLose.cs +++ b/Si_HQlessHumansLose/Si_HQlessHumansLose.cs @@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License using System; using SilicaAdminMod; -[assembly: MelonInfo(typeof(HQlessHumansLose), "[Si] HQless Humans Lose", "1.2.8", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(HQlessHumansLose), "HQless Humans Lose", "1.2.9", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -76,7 +76,7 @@ static void HandleTimerSendLostMessage(object? source, ElapsedEventArgs e) lostMessageTimerExpired = true; } - public static bool OneFactionEliminated() + public static bool OneFactionAlreadyEliminated() { int TeamsWithMajorStructures = 0; for (int i = 0; i < Team.Teams.Count; i++) @@ -89,13 +89,13 @@ public static bool OneFactionEliminated() } } - if (TeamsWithMajorStructures < 3) + if (TeamsWithMajorStructures < 2) { - MelonLogger.Msg("OneFactionEliminated: true"); + MelonLogger.Msg("OneFactionAlreadyEliminated: true"); return true; } - MelonLogger.Msg("OneFactionEliminated: false"); + MelonLogger.Msg("OneFactionAlreadyEliminated: false"); return false; } @@ -107,7 +107,7 @@ public static void EliminateTeam(Team team) MelonLogger.Msg("Eliminating team " + team.TeamName + " on versus mode " + versusMode.ToString()); // are there still two remaining factions after this one is eliminated? - if (versusMode == MP_Strategy.ETeamsVersus.HUMANS_VS_HUMANS_VS_ALIENS && !OneFactionEliminated()) + if (versusMode == MP_Strategy.ETeamsVersus.HUMANS_VS_HUMANS_VS_ALIENS && !OneFactionAlreadyEliminated()) { // destroy structures for (int i = 0; i < team.Structures.Count; i++) @@ -146,6 +146,8 @@ private static void DestroyAllUnits(Team team) // introduce a delay so clients can see chat message after round ends private static void DelayTeamLostMessage(Team team) { + MelonLogger.Msg("Starting delay lost timer for team " + team.TeamName); + lostMessageTimerExpired = false; losingTeam = team; @@ -238,6 +240,8 @@ private static void Postfix(ConstructionSite __instance, bool __0) return; } + MelonLogger.Msg("Structure construction destroyed: " + __instance.name); + Team constructionSiteTeam = __instance.Team; String rootStructureMatchText = GetRootStructurePrefix(constructionSiteTeam); if (!__instance.ToString().Contains(rootStructureMatchText)) @@ -295,7 +299,7 @@ private static void Postfix(Team __instance) #endif private static class ApplyPatch_GetHasLost { - private static void Postfix(StrategyTeamSetup __instance, bool __result) + private static void Postfix(StrategyTeamSetup __instance, ref bool __result) { // only spend the CPU if the team is about to lose if (__result == true && GameMode.CurrentGameMode.GameOngoing) @@ -316,7 +320,7 @@ private static void Postfix(StrategyTeamSetup __instance, bool __result) #endif private static class ApplyPatch_GetHasAnyMajorStructures { - private static void Postfix(Team __instance, bool __result) + private static void Postfix(Team __instance, ref bool __result) { // only spend the CPU if the team is about to lose if (__result == false && GameMode.CurrentGameMode.GameOngoing) @@ -383,6 +387,8 @@ private static void Postfix(MP_Strategy __instance, Structure __0, EDamageType _ return; } + MelonLogger.Msg("Structure destroyed: " + __0.name); + Team structureTeam = __0.Team; if (structureTeam == null) {