From f84b5cc909c76cea9b57b0e05f23f9558df48314 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Sat, 26 Sep 2026 13:17:21 +0200 Subject: [PATCH] more fixes --- Gamemodes/Deathrace.cs | 15 ++---------- Modules/CustomRolesHelper.cs | 14 +++++++---- Modules/Extensions/CollectionExtensions.cs | 8 +++++++ Patches/MatchInfoGuidePatch.cs | 27 ++++++++++++++++++++-- Patches/SabotageSystemPatch.cs | 4 ++-- Resources/Lang/en_US.json | 2 +- Roles/Standard/Impostor/Killing/Bomber.cs | 2 +- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/Gamemodes/Deathrace.cs b/Gamemodes/Deathrace.cs index 72e17326b..aff122705 100644 --- a/Gamemodes/Deathrace.cs +++ b/Gamemodes/Deathrace.cs @@ -212,8 +212,6 @@ public static class Deathrace SmokeSpeedReduction = SmokeSpeedReductionOption.GetFloat(); EnergyDrinkSpeedIncreasement = EnergyDrinkSpeedIncreasementOption.GetFloat(); PowerUpPickupRange = PowerUpPickupRangeOption.GetFloat(); - - Main.AllPlayerSpeed.SetAllValues(Main.MinSpeed); } public static IEnumerator GameStart() @@ -260,14 +258,6 @@ public static class Deathrace yield return new WaitForSecondsRealtime(4f); NameNotifyManager.Reset(); } - - if (Main.CurrentMap == MapNames.Airship) - players.MassTP(new RandomSpawn.AirshipSpawnMap().Positions[Clockwise ? Track[^1] : Track[0]]); - } - else if (Main.CurrentMap == MapNames.Airship) - { - yield return new WaitForSecondsRealtime(3f); - players.MassTP(new RandomSpawn.AirshipSpawnMap().Positions[Clockwise ? Track[^1] : Track[0]]); } for (var i = 5; i > 0; i--) @@ -277,12 +267,11 @@ public static class Deathrace yield return new WaitForSecondsRealtime(1f); } + players.MassTP(RandomSpawn.SpawnMap.GetSpawnMap().Positions[Clockwise ? Track[^1] : Track[0]]); + NameNotifyManager.Reset(); Utils.NotifyRoles(); - Main.AllPlayerSpeed.SetAllValues(Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod)); - Utils.SyncAllSettings(); - GameGoing = true; } diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index 76c93a049..77a49cf12 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -1737,16 +1737,22 @@ internal static class CustomRolesHelper public int GetMode() { - return Options.GetRoleSpawnMode(role); + return role switch + { + CustomRoles.Nuker => !CustomRoles.Bomber.IsEnable() ? 0 : Bomber.NukerChance.GetInt(), + CustomRoles.Bard => !CustomRoles.Arrogance.IsEnable() ? 0 : Arrogance.BardChance.GetInt(), + CustomRoles.Sunnyboy => !CustomRoles.Jester.IsEnable() ? 0 : Jester.SunnyboyChance.GetInt(), + _ => Options.GetRoleSpawnMode(role) + }; } public bool IsEnable() { return role switch { - CustomRoles.Nuker => Bomber.NukerChance.GetInt() > 0, - CustomRoles.Bard => Arrogance.BardChance.GetInt() > 0, - CustomRoles.Sunnyboy => Jester.SunnyboyChance.GetInt() > 0, + CustomRoles.Nuker => CustomRoles.Bomber.IsEnable() && Bomber.NukerChance.GetInt() > 0, + CustomRoles.Bard => CustomRoles.Arrogance.IsEnable() && Arrogance.BardChance.GetInt() > 0, + CustomRoles.Sunnyboy => CustomRoles.Jester.IsEnable() && Jester.SunnyboyChance.GetInt() > 0, _ => role.GetCount() > 0 }; } diff --git a/Modules/Extensions/CollectionExtensions.cs b/Modules/Extensions/CollectionExtensions.cs index 68eec3383..8d05efc13 100644 --- a/Modules/Extensions/CollectionExtensions.cs +++ b/Modules/Extensions/CollectionExtensions.cs @@ -42,7 +42,11 @@ public static class CollectionExtensions /// public void SetAllValues(TValue value) { +#if IL2CPP + foreach (TKey key in dictionary.Keys) +#else foreach (TKey key in dictionary.Keys.ToArray()) +#endif dictionary[key] = value; } @@ -52,7 +56,11 @@ public static class CollectionExtensions /// The function to adjust the values with public void AdjustAllValues(Func adjust) { +#if IL2CPP + foreach (TKey key in dictionary.Keys) +#else foreach (TKey key in dictionary.Keys.ToArray()) +#endif dictionary[key] = adjust(dictionary[key]); } diff --git a/Patches/MatchInfoGuidePatch.cs b/Patches/MatchInfoGuidePatch.cs index 4a5fb0e12..71a68ae60 100644 --- a/Patches/MatchInfoGuidePatch.cs +++ b/Patches/MatchInfoGuidePatch.cs @@ -153,9 +153,32 @@ public static class MatchInfoGuidePatch private static void SetAlternativeText(MatchInfoGuide __instance) { - CustomGameMode currentGameMode = Options.CurrentGameMode; var tmp = __instance.rolesEnabledMessage.GetComponent(); tmp.DestroyTranslator(); - tmp.text = currentGameMode == CustomGameMode.Standard ? TranslationController.Instance.GetString(StringNames.MatchInfoGuideNoRolesMessage) : Translator.GetString(Main.HasPlayedGM.ContainsKey(currentGameMode) ? $"GameModeTutorial.{currentGameMode}" : $"ModeDescribe.{currentGameMode}"); + tmp.text = GetGameModeDescription(); + } + + private static string GetGameModeDescription() + { + CustomGameMode currentGameMode = Options.CurrentGameMode; + + if (currentGameMode == CustomGameMode.Standard) + return TranslationController.Instance.GetString(StringNames.MatchInfoGuideNoRolesMessage); + + if (Main.HasPlayedGM.ContainsKey(currentGameMode)) + return Translator.GetString($"GameModeTutorial.{currentGameMode}"); + + string description = ""; + description += Translator.GetString($"ModeDescribe.{currentGameMode}").Replace('\n', ' ').Replace(" ", " "); + + for (int i = 80; i < description.Length; i += 80) + { + int index = description.LastIndexOf(' ', i); + if (index == -1) continue; + description = description.Remove(index, 1).Insert(index, "\n"); + } + + description += ""; + return description; } } \ No newline at end of file diff --git a/Patches/SabotageSystemPatch.cs b/Patches/SabotageSystemPatch.cs index 87ddcab32..be0177acd 100644 --- a/Patches/SabotageSystemPatch.cs +++ b/Patches/SabotageSystemPatch.cs @@ -485,8 +485,8 @@ public static class SabotageSystemTypeUpdateSystemPatch try { - if (Main.PlayerStates.TryGetValue(player.PlayerId, out PlayerState state)) - state.Role.OnSabotage(player); + if (Main.PlayerStates.TryGetValue(player.PlayerId, out PlayerState state) && !state.Role.OnSabotage(player)) + return false; } catch (Exception e) { Utils.ThrowException(e); } } diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 3f69bec86..e5aa903d6 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -4587,7 +4587,7 @@ "HotPotato": "HOT POTATO", "ModeHotPotato": "Gamemode: Hot Potato", "ModeDescribe.HotPotato": "In the Hot Potato gamemode, one player always has the hot potato, and they can pass it to anyone by going near someone. Each X seconds (X is set by the host), the player who holds the hot potato dies. The last player alive wins!\\n\\nNote: You cannot pass the hot potato to the player that just gave it to you (their name is colored in cyan, it means they cannot get the hot potato) unless there are only 2 players left.", - "GameModeTutorial.HotPotato": "The current game mode is <#e8cd46>Hot Potato.\\nThe person with a black name holds the hot potato.\\nThey can pass it to someone by going near them.\\nThe previous holder's name is colored in cyan, they cannot regain\\nthe hot potato until someone else got it, unless only 2 players remain.\\nWhen the time limit ends, the holder of the hot potato dies, and the timer resets,\\nthe hot potato is assigned to a random player. Be the last player alive to win!", + "GameModeTutorial.HotPotato": "The current game mode is <#e8cd46>Hot Potato.\\nBlack name = potato holder.\\nCyan name = previous holder. Can't pass it to them unless it's 1v1.\\nTimer expires = current holder dies, potato given to random player.\\nLast one alive wins!", "HotPotato_ExtraTimeOnAirship": "Extra Time on Airship", "HotPotato_ExtraTimeOnFungle": "Extra Time on Fungle", "HotPotato_HolderCanPassViaKillButton": "Holders Pass The Potato Via Kill Button Instead Of Proximity", diff --git a/Roles/Standard/Impostor/Killing/Bomber.cs b/Roles/Standard/Impostor/Killing/Bomber.cs index 52db95fb6..b3751dd39 100644 --- a/Roles/Standard/Impostor/Killing/Bomber.cs +++ b/Roles/Standard/Impostor/Killing/Bomber.cs @@ -50,7 +50,7 @@ internal class Bomber : RoleBase BomberDiesInExplosion = new BooleanOptionItem(2032, "BomberDiesInExplosion", false, TabGroup.ImpostorRoles) .SetParent(CustomRoleSpawnChances[CustomRoles.Bomber]); - NukerChance = new IntegerOptionItem(2033, "NukerChance", new(0, 100, 5), 5, TabGroup.ImpostorRoles) + NukerChance = new IntegerOptionItem(2033, "NukerChance", new(0, 100, 5), 0, TabGroup.ImpostorRoles) .SetParent(CustomRoleSpawnChances[CustomRoles.Bomber]) .SetValueFormat(OptionFormat.Percent);