mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
fixes
This commit is contained in:
1 parent
1604c584dc
commit
3074168357
10 files changed
+54
-31
No files matched your search
@@ -93,7 +93,7 @@ internal static class CustomRoleSelector
|
||||
foreach (CustomRoles role in Enum.GetValues<CustomRoles>())
|
||||
{
|
||||
int chance = role.GetMode();
|
||||
if (role.IsVanilla() || chance == 0 || role.IsAdditionRole() || (role.OnlySpawnsWithPets() && !Options.UsePets.GetBool()) || (role != CustomRoles.Randomizer && role.IsCrewmate() && Options.AprilFoolsMode.GetBool()) || CustomHnS.AllHnSRoles.Contains(role) || xorBannedRoles.Contains(role)) continue;
|
||||
if (role.IsVanilla() || chance == 0 || role.IsAdditionRole() || (role.OnlySpawnsWithPets() && !Options.UsePets.GetBool()) || CustomHnS.AllHnSRoles.Contains(role) || xorBannedRoles.Contains(role)) continue;
|
||||
|
||||
switch (role)
|
||||
{
|
||||
@@ -122,12 +122,6 @@ internal static class CustomRoleSelector
|
||||
|
||||
int count = role.GetCount();
|
||||
|
||||
if (role == CustomRoles.Randomizer && Options.AprilFoolsMode.GetBool())
|
||||
{
|
||||
chance = 100;
|
||||
count = 15;
|
||||
}
|
||||
|
||||
RoleAssignInfo info = new(role, chance, count);
|
||||
|
||||
if (role.IsCoven()) Roles[RoleAssignType.Coven].Add(info);
|
||||
|
||||
@@ -111,6 +111,8 @@ public class PlayerState(byte playerId)
|
||||
if (Main.IntroDestroyed && MainRole != CustomRoles.NotAssigned && (RoleHistory.Count == 0 || RoleHistory[^1] != MainRole))
|
||||
RoleHistory.Add(MainRole);
|
||||
|
||||
Divinator.OnRoleChange(PlayerId, MainRole, role);
|
||||
|
||||
bool previousHasTasks = Utils.HasTasks(Player.Data, false);
|
||||
|
||||
countTypes = role.GetCountTypes();
|
||||
|
||||
@@ -2279,6 +2279,7 @@ public static class Options
|
||||
|
||||
AprilFoolsMode = new BooleanOptionItem(23860, "AprilFoolsMode", Main.IsAprilFools, TabGroup.TaskSettings)
|
||||
.SetGameMode(CustomGameMode.Standard)
|
||||
.SetHidden(true)
|
||||
.SetHeader(true)
|
||||
.SetColor(new Color32(255, 153, 153, byte.MaxValue));
|
||||
|
||||
|
||||
@@ -1506,7 +1506,6 @@ public static class Utils
|
||||
{
|
||||
if (state.RoleHistory.Count > 0)
|
||||
{
|
||||
state.RoleHistory.Add(state.MainRole);
|
||||
string join = string.Join(" > ", state.RoleHistory.ConvertAll(x => x.ToColoredString()));
|
||||
sb.AppendLine($"{id.ColoredPlayerName()}: {join}");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.Data;
|
||||
using AmongUs.GameOptions;
|
||||
@@ -8,6 +7,7 @@ using EHR.Neutral;
|
||||
using EHR.Patches;
|
||||
using HarmonyLib;
|
||||
using Hazel;
|
||||
using Il2CppSystem.Collections.Generic;
|
||||
using InnerNet;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -315,17 +315,24 @@ public static class GameStartManagerPatch
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
foreach (ClientData client in AmongUsClient.Instance.allClients)
|
||||
List<ClientData> allClients = AmongUsClient.Instance.allClients;
|
||||
|
||||
lock (allClients)
|
||||
{
|
||||
if (client.Character == null) continue;
|
||||
|
||||
var dummyComponent = client.Character.GetComponent<DummyBehaviour>();
|
||||
if (dummyComponent != null && dummyComponent.enabled) continue;
|
||||
|
||||
if (!MatchVersions(client.Character.PlayerId, true))
|
||||
// ReSharper disable once ForCanBeConvertedToForeach
|
||||
for (var index = 0; index < allClients.Count; index++)
|
||||
{
|
||||
canStartGame = false;
|
||||
mismatchedClientName = client.Character.PlayerId.ColoredPlayerName();
|
||||
ClientData client = allClients[index];
|
||||
if (client.Character == null) continue;
|
||||
|
||||
var dummyComponent = client.Character.GetComponent<DummyBehaviour>();
|
||||
if (dummyComponent != null && dummyComponent.enabled) continue;
|
||||
|
||||
if (!MatchVersions(client.Character.PlayerId, true))
|
||||
{
|
||||
canStartGame = false;
|
||||
mismatchedClientName = client.Character.PlayerId.ColoredPlayerName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +485,7 @@ public static class GameStartRandomMap
|
||||
public static byte SelectRandomMap()
|
||||
{
|
||||
var rand = IRandom.Instance;
|
||||
List<byte> randomMaps = [];
|
||||
System.Collections.Generic.List<byte> randomMaps = [];
|
||||
|
||||
int tempRand = rand.Next(1, 100);
|
||||
|
||||
|
||||
@@ -110,7 +110,13 @@ static class CoShowIntroPatch
|
||||
introCutscene.ImpostorTitle.gameObject.SetActive(false);
|
||||
|
||||
List<PlayerControl> show = IntroCutscene.SelectTeamToShow((Func<NetworkedPlayerInfo, bool>)(pcd => !PlayerControl.LocalPlayer.Data.Role.IsImpostor || pcd.Role.TeamType == PlayerControl.LocalPlayer.Data.Role.TeamType));
|
||||
if (show == null || show.Count < 1) Logger.Error("IntroCutscene :: CoBegin() :: teamToShow is EMPTY or NULL", "BASE GAME LOGGER");
|
||||
|
||||
if (show == null || show.Count < 1)
|
||||
{
|
||||
Logger.Error("IntroCutscene :: CoBegin() :: teamToShow is EMPTY or NULL", "BASE GAME LOGGER");
|
||||
show = new();
|
||||
show.Add(PlayerControl.LocalPlayer);
|
||||
}
|
||||
|
||||
if (PlayerControl.LocalPlayer.Data.Role.IsImpostor)
|
||||
introCutscene.ImpostorText.gameObject.SetActive(false);
|
||||
|
||||
@@ -1899,7 +1899,9 @@ internal static class FixedUpdatePatch
|
||||
if (Lovers.LoverDieConsequence.GetValue() == 0 || Main.IsLoversDead || (!Main.LoversPlayers.Exists(player => !player.IsAlive() && player.PlayerId == deathId) && !force)) return;
|
||||
|
||||
Main.IsLoversDead = true;
|
||||
PlayerControl partnerPlayer = Main.LoversPlayers.First(player => player.PlayerId != deathId && player.IsAlive());
|
||||
PlayerControl partnerPlayer = Main.LoversPlayers.FirstOrDefault(player => player.PlayerId != deathId && player.IsAlive());
|
||||
|
||||
if (partnerPlayer == null) return;
|
||||
|
||||
if (Lovers.LoverDieConsequence.GetValue() == 2)
|
||||
{
|
||||
@@ -2312,9 +2314,6 @@ public static class PlayerControlFixMixedUpOutfitPatch
|
||||
if (!__instance.IsAlive()) return;
|
||||
|
||||
__instance.cosmetics.ToggleNameVisible(true);
|
||||
|
||||
if (AmongUsClient.Instance.AmHost && __instance.AmOwner)
|
||||
ReportDeadBodyPatch.CanReport.SetAllValues(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ public static class MushroomMixupSabotageSystemPatch
|
||||
|
||||
ReportDeadBodyPatch.CanReport.SetAllValues(false);
|
||||
Logger.Info("Disable Reporting", "MushroomMixupSabotageSystem");
|
||||
LateTask.New(() => ReportDeadBodyPatch.CanReport.SetAllValues(true), Options.SabotageTimeControl.GetBool() ? Options.FungleMushroomMixupDuration.GetFloat() : 10f, "Enable Reporting After Mushroom Mixup");
|
||||
|
||||
if (!Options.SabotageTimeControl.GetBool()) return;
|
||||
|
||||
@@ -178,8 +179,6 @@ public static class MushroomMixupSabotageSystemPatch
|
||||
{
|
||||
// After MushroomMixup sabotage, shapeshift cooldown sets to 0
|
||||
Main.AllAlivePlayerControls.DoIf(x => x.GetRoleTypes() != RoleTypes.Engineer, x => x.RpcResetAbilityCooldown());
|
||||
ReportDeadBodyPatch.CanReport.SetAllValues(true);
|
||||
Logger.Info("Enable Reporting", "MushroomMixupSabotageSystem");
|
||||
}, 1.2f, "Reset Ability Cooldown Arter Mushroom Mixup");
|
||||
|
||||
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
|
||||
@@ -187,9 +186,6 @@ public static class MushroomMixupSabotageSystemPatch
|
||||
if (!pc.Is(CustomRoleTypes.Impostor) && pc.HasDesyncRole())
|
||||
Utils.NotifyRoles(SpecifySeer: pc, ForceLoop: true, MushroomMixup: true);
|
||||
}
|
||||
|
||||
ReportDeadBodyPatch.CanReport.SetAllValues(true);
|
||||
Logger.Info("Enable Reporting", "MushroomMixupSabotageSystem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public class Astral : RoleBase
|
||||
|
||||
AURoleOptions.EngineerCooldown = AbilityCooldown.GetFloat();
|
||||
AURoleOptions.EngineerInVentMaxTime = 1f;
|
||||
|
||||
try { AURoleOptions.GuardianAngelCooldown = 900f; }
|
||||
catch { }
|
||||
}
|
||||
|
||||
public override void OnEnterVent(PlayerControl pc, Vent vent)
|
||||
@@ -68,6 +71,9 @@ public class Astral : RoleBase
|
||||
|
||||
pc.Exiled();
|
||||
CustomRpcSender.Create("Astral", (SendOption)1).AutoStartRpc(pc.NetId, 4).EndRpc().SendMessage();
|
||||
LateTask.New(() => pc.RpcSetRoleDesync(RoleTypes.GuardianAngel, pc.OwnerId), 0.2f, log: false);
|
||||
LateTask.New(pc.RpcResetAbilityCooldown, 0.4f, log: false);
|
||||
pc.MarkDirtySettings();
|
||||
|
||||
BackTS = Utils.TimeStamp + AbilityDuration.GetInt() + 1;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, AstralId, BackTS);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Divinator : RoleBase
|
||||
|
||||
public static readonly List<byte> DidVote = [];
|
||||
|
||||
private static Dictionary<byte, HashSet<CustomRoles>> AllPlayerRoleList = [];
|
||||
private static Dictionary<byte, List<CustomRoles>> AllPlayerRoleList = [];
|
||||
|
||||
public override bool IsEnable => PlayerIdList.Count > 0;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class Divinator : RoleBase
|
||||
.ToArray();
|
||||
|
||||
roleList.Do(x => x.RoleList.Insert(IRandom.Instance.Next(x.RoleList.Count), x.Player.GetCustomRole()));
|
||||
AllPlayerRoleList = roleList.ToDictionary(x => x.Player.PlayerId, x => x.RoleList.ToHashSet());
|
||||
AllPlayerRoleList = roleList.ToDictionary(x => x.Player.PlayerId, x => x.RoleList);
|
||||
|
||||
Logger.Info(string.Join(" ---- ", AllPlayerRoleList.Select(x => $"ID {x.Key} ({x.Key.GetPlayer().GetNameWithRole()}): {string.Join(", ", x.Value)}")), "Divinator Roles");
|
||||
}, 8f, log: false);
|
||||
@@ -135,4 +135,17 @@ public class Divinator : RoleBase
|
||||
Main.DontCancelVoteList.Add(player.PlayerId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OnRoleChange(byte id, CustomRoles previousRole, CustomRoles newRole)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!AllPlayerRoleList.TryGetValue(id, out List<CustomRoles> list)) return;
|
||||
|
||||
int index = list.IndexOf(previousRole);
|
||||
list.Remove(previousRole);
|
||||
list.Insert(index, newRole);
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user