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
3dc79bf8ef
commit
212515dc52
5 files changed
+37
-113
No files matched your search
@@ -11,14 +11,17 @@ internal static class CustomRoleSelector
|
||||
{
|
||||
public static Dictionary<byte, CustomRoles> RoleResult;
|
||||
public static List<CustomRoles> AddonRolesList = [];
|
||||
public static int AddScientistNum;
|
||||
public static int AddEngineerNum;
|
||||
public static int AddShapeshifterNum;
|
||||
public static int AddNoisemakerNum;
|
||||
public static int AddTrackerNum;
|
||||
public static int AddPhantomNum;
|
||||
public static int AddViperNum;
|
||||
public static int AddDetectiveNum;
|
||||
public static Dictionary<RoleTypes, int> AddRoleTypesNum = new()
|
||||
{
|
||||
[RoleTypes.Scientist] = 0,
|
||||
[RoleTypes.Engineer] = 0,
|
||||
[RoleTypes.Shapeshifter] = 0,
|
||||
[RoleTypes.Noisemaker] = 0,
|
||||
[RoleTypes.Tracker] = 0,
|
||||
[RoleTypes.Phantom] = 0,
|
||||
[RoleTypes.Viper] = 0,
|
||||
[RoleTypes.Detective] = 0
|
||||
};
|
||||
|
||||
public static readonly Dictionary<CustomGameMode, CustomRoles> GameModeRoles = new()
|
||||
{
|
||||
@@ -510,46 +513,26 @@ internal static class CustomRoleSelector
|
||||
public static void CalculateVanillaRoleCount()
|
||||
{
|
||||
// Calculate the number of base roles
|
||||
AddEngineerNum = 0;
|
||||
AddScientistNum = 0;
|
||||
AddShapeshifterNum = 0;
|
||||
AddNoisemakerNum = 0;
|
||||
AddTrackerNum = 0;
|
||||
AddPhantomNum = 0;
|
||||
AddViperNum = 0;
|
||||
AddDetectiveNum = 0;
|
||||
AddRoleTypesNum = new()
|
||||
{
|
||||
[RoleTypes.Scientist] = 0,
|
||||
[RoleTypes.Engineer] = 0,
|
||||
[RoleTypes.Shapeshifter] = 0,
|
||||
[RoleTypes.Noisemaker] = 0,
|
||||
[RoleTypes.Tracker] = 0,
|
||||
[RoleTypes.Phantom] = 0,
|
||||
[RoleTypes.Viper] = 0,
|
||||
[RoleTypes.Detective] = 0,
|
||||
};
|
||||
|
||||
foreach (CustomRoles role in RoleResult.Values)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (role.GetVNRole())
|
||||
{
|
||||
case CustomRoles.Scientist:
|
||||
AddScientistNum++;
|
||||
break;
|
||||
case CustomRoles.Engineer:
|
||||
AddEngineerNum++;
|
||||
break;
|
||||
case CustomRoles.Shapeshifter:
|
||||
AddShapeshifterNum++;
|
||||
break;
|
||||
case CustomRoles.Noisemaker:
|
||||
AddNoisemakerNum++;
|
||||
break;
|
||||
case CustomRoles.Tracker:
|
||||
AddTrackerNum++;
|
||||
break;
|
||||
case CustomRoles.Phantom:
|
||||
AddPhantomNum++;
|
||||
break;
|
||||
case CustomRoles.Viper:
|
||||
AddViperNum++;
|
||||
break;
|
||||
case CustomRoles.Detective:
|
||||
AddDetectiveNum++;
|
||||
break;
|
||||
}
|
||||
var baseRole = role.GetVNRole();
|
||||
|
||||
if (Enum.TryParse(baseRole.ToString(), true, out RoleTypes roleTypes) && AddRoleTypesNum.ContainsKey(roleTypes))
|
||||
AddRoleTypesNum[roleTypes]++;
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
+4
-42
@@ -1839,7 +1839,8 @@ public static class Utils
|
||||
text = text.Replace("color=#", "#");
|
||||
title = title.Replace("color=", string.Empty);
|
||||
|
||||
bool vanilla = GameStates.CurrentServerType == GameStates.ServerType.Vanilla;
|
||||
var serverType = GameStates.CurrentServerType;
|
||||
bool vanilla = serverType == GameStates.ServerType.Vanilla;
|
||||
|
||||
SendOption sendOption = SendOption.Reliable;
|
||||
|
||||
@@ -1970,6 +1971,8 @@ public static class Utils
|
||||
|
||||
int fullRpcSizeLimit = Options.MessageRpcSizeLimit.GetInt();
|
||||
if (vanilla && fullRpcSizeLimit > 1200) fullRpcSizeLimit = 1200;
|
||||
if (serverType == GameStates.ServerType.Niko && fullRpcSizeLimit > 1400) fullRpcSizeLimit = 1400;
|
||||
|
||||
string resetName = Main.AllPlayerNames.GetValueOrDefault(sender.PlayerId, string.Empty);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -3874,47 +3877,6 @@ public static class Utils
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerator SendGameDataContinuously()
|
||||
{
|
||||
float waitTime = GameData.Instance.AllPlayers.Count switch
|
||||
{
|
||||
<= 15 => 1f,
|
||||
<= 20 => 0.8f,
|
||||
_ => 0.5f
|
||||
};
|
||||
|
||||
while (GameStates.InGame && !GameStates.IsEnded && ShipStatus.Instance)
|
||||
{
|
||||
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks)
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(10f);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var index = 0; index < GameData.Instance.AllPlayers.Count; index++)
|
||||
{
|
||||
NetworkedPlayerInfo playerInfo = GameData.Instance.AllPlayers[index];
|
||||
|
||||
if (!playerInfo || (Astral.On && Main.PlayerStates.TryGetValue(playerInfo.PlayerId, out PlayerState state) && state.Role is Astral { Timer: not null }) || (SoulCollector.On && Main.PlayerStates.Values.Any(x => x.Role is SoulCollector sc && sc.ToExile.Contains(playerInfo.PlayerId)))) continue;
|
||||
|
||||
playerInfo.IsDead = !playerInfo.Object.IsAlive();
|
||||
|
||||
var qa = playerInfo.SendGameData(SendOption.None);
|
||||
yield return qa.Wait();
|
||||
|
||||
if (qa.Dropped || !GameStates.InGame || GameStates.IsEnded || !ShipStatus.Instance)
|
||||
{
|
||||
Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously));
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return new WaitForSecondsRealtime(waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously));
|
||||
}
|
||||
|
||||
public static void SendGameDataTo(int targetClientId)
|
||||
{
|
||||
|
||||
@@ -390,7 +390,7 @@ internal static class ChatCommands
|
||||
|
||||
if (GameStates.InGame && (Silencer.ForSilencer.Contains(PlayerControl.LocalPlayer.PlayerId) || (Main.PlayerStates[PlayerControl.LocalPlayer.PlayerId].Role is Dad { IsEnable: true } dad && dad.UsingAbilities.Contains(Dad.Ability.GoForMilk))) && PlayerControl.LocalPlayer.IsAlive()) goto Canceled;
|
||||
|
||||
if (GameStates.IsMeeting && Exorcist.AbilityEndTS > Utils.TimeStamp)
|
||||
if (GameStates.IsMeeting && Exorcist.AbilityEndTS > Utils.TimeStamp && !text.StartsWith("/cmd"))
|
||||
{
|
||||
LateTask.New(() =>
|
||||
{
|
||||
@@ -3408,14 +3408,14 @@ internal static class ChatCommands
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameStates.IsMeeting && Exorcist.AbilityEndTS > now && player.IsAlive())
|
||||
if (text.StartsWith("\n")) text = text[1..];
|
||||
|
||||
if (GameStates.IsMeeting && Exorcist.AbilityEndTS > now && player.IsAlive() && !text.StartsWith("/cmd"))
|
||||
{
|
||||
player.RpcGuesserMurderPlayer();
|
||||
player.SetRealKiller(Main.EnumeratePlayerControls().FirstOrDefault(x => x.Is(CustomRoles.Exorcist)));
|
||||
}
|
||||
|
||||
if (text.StartsWith("\n")) text = text[1..];
|
||||
|
||||
switch (Options.CurrentGameMode)
|
||||
{
|
||||
case CustomGameMode.TheMindGame when !player.IsModdedClient():
|
||||
|
||||
@@ -1395,7 +1395,6 @@ internal static class IntroCutsceneDestroyPatch
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync()), 6f, "NotifyEveryoneAsync On Game Start");
|
||||
LateTask.New(Utils.MarkEveryoneDirtySettings, 0.5f, "SyncAllSettings On Game Start");
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(ShipStatusFixedUpdatePatch.Postfix()), 5f, "ShipStatusFixedUpdatePatch Postfix Start");
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(Utils.SendGameDataContinuously()), 10f, "SendGameDataContinuously Start");
|
||||
|
||||
Utils.CheckAndSetVentInteractions();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.Data;
|
||||
using AmongUs.GameOptions;
|
||||
using Assets.CoreScripts;
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using EHR.Gamemodes;
|
||||
using EHR.Modules;
|
||||
@@ -379,25 +377,9 @@ internal static class StartGameHostPatch
|
||||
private static AmongUsClient AUClient;
|
||||
|
||||
public static readonly Dictionary<CustomRoles, List<byte>> BasisChangingAddons = [];
|
||||
private static Dictionary<RoleTypes, int> RoleTypeNums = [];
|
||||
|
||||
private static RoleOptionsCollectionV10 RoleOpt => Main.NormalOptions.roleOptions;
|
||||
|
||||
private static void UpdateRoleTypeNums()
|
||||
{
|
||||
RoleTypeNums = new()
|
||||
{
|
||||
{ RoleTypes.Scientist, AddScientistNum },
|
||||
{ RoleTypes.Engineer, AddEngineerNum },
|
||||
{ RoleTypes.Shapeshifter, AddShapeshifterNum },
|
||||
{ RoleTypes.Noisemaker, AddNoisemakerNum },
|
||||
{ RoleTypes.Phantom, AddPhantomNum },
|
||||
{ RoleTypes.Tracker, AddTrackerNum },
|
||||
{ RoleTypes.Detective, AddDetectiveNum },
|
||||
{ RoleTypes.Viper, AddViperNum }
|
||||
};
|
||||
}
|
||||
|
||||
private static System.Collections.IEnumerator WaitAndSmoothlyUpdate(this LoadingBarManager loadingBarManager, float startPercent, float targetPercent, float duration, string loadingText)
|
||||
{
|
||||
float startTime = Time.time;
|
||||
@@ -591,9 +573,7 @@ internal static class StartGameHostPatch
|
||||
SelectAddonRoles();
|
||||
CalculateVanillaRoleCount();
|
||||
|
||||
UpdateRoleTypeNums();
|
||||
|
||||
foreach ((RoleTypes roleTypes, int roleNum) in RoleTypeNums)
|
||||
foreach ((RoleTypes roleTypes, int roleNum) in AddRoleTypesNum)
|
||||
RoleOpt.SetRoleRate(roleTypes, roleNum, roleNum > 0 ? 100 : RoleOpt.GetChancePerGame(roleTypes));
|
||||
|
||||
Statistics.OnRoleSelectionComplete();
|
||||
@@ -966,7 +946,7 @@ internal static class StartGameHostPatch
|
||||
pc.ResetKillCooldown(false);
|
||||
|
||||
|
||||
foreach (KeyValuePair<RoleTypes, int> roleType in RoleTypeNums)
|
||||
foreach (KeyValuePair<RoleTypes, int> roleType in AddRoleTypesNum)
|
||||
{
|
||||
var roleNum = 0;
|
||||
roleNum -= roleType.Value;
|
||||
@@ -1118,7 +1098,7 @@ internal static class StartGameHostPatch
|
||||
Main.PlayerStates[player.PlayerId].SetMainRole(role);
|
||||
|
||||
RoleTypes selfRole = isHost ? baseRole == RoleTypes.Shapeshifter ? RoleTypes.Shapeshifter : hostBaseRole : baseRole;
|
||||
RoleTypes othersRole = isHost ? RoleTypes.Crewmate : RoleTypes.Scientist;
|
||||
const RoleTypes othersRole = RoleTypes.Crewmate;
|
||||
|
||||
// Set Desync role for self and for others
|
||||
foreach (PlayerControl target in Main.EnumeratePlayerControls())
|
||||
|
||||
Reference in new issue
Block a user