This commit is contained in:
Gurge44 committed 2025-12-20 12:54:22 +01:00
1 parent c0518c5a24
commit 4ac55c964a
12 files changed
+59 -19

No files matched your search

-1
View File
@@ -575,7 +575,6 @@ public enum CustomRoles
Physicist,
Rascal,
Reach,
Recruit,
Rookie,
Trainee,
Schizophrenic,
+2 -2
View File
@@ -8,8 +8,8 @@
<Description>EHR</Description>
<Authors>Gurge44</Authors>
<LangVersion>preview</LangVersion>
<!--<AmongUs>D:\SteamLibrary\steamapps\common\Among Us</AmongUs>-->
<AmongUs>C:\Program Files\Epic Games\AmongUs</AmongUs>
<AmongUs>D:\SteamLibrary\steamapps\common\Among Us</AmongUs>
<!--<AmongUs>C:\Program Files\Epic Games\AmongUs</AmongUs>-->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>True</Optimize>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
+1 -1
View File
@@ -600,7 +600,7 @@ public static class BedWars
public static void Postfix(PlayerControl __instance)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || Options.CurrentGameMode != CustomGameMode.BedWars || !Main.IntroDestroyed || GameStates.IsEnded || __instance == null || __instance.PlayerId >= 254 || Utils.GameStartTimeStamp + 25 > Utils.TimeStamp) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || Options.CurrentGameMode != CustomGameMode.BedWars || !Main.IntroDestroyed || GameStates.IsEnded || __instance == null || __instance.PlayerId >= 254 || IntroCutsceneDestroyPatch.IntroDestroyTS + 10 > Utils.TimeStamp) return;
long now = Utils.TimeStamp;
+1 -1
View File
@@ -711,7 +711,7 @@ public static class CaptureTheFlag
{
public static void Postfix(PlayerControl __instance)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || Options.CurrentGameMode != CustomGameMode.CaptureTheFlag || !Main.IntroDestroyed || __instance.PlayerId >= 254 || WinnerData.Team != "No one wins" || Utils.GameStartTimeStamp + 15 > Utils.TimeStamp) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || Options.CurrentGameMode != CustomGameMode.CaptureTheFlag || !Main.IntroDestroyed || __instance.PlayerId >= 254 || WinnerData.Team != "No one wins" || IntroCutsceneDestroyPatch.IntroDestroyTS + 5 > Utils.TimeStamp) return;
if (__instance.IsHost())
{
+1 -1
View File
@@ -136,7 +136,7 @@ internal static class HotPotato
public static void Postfix(PlayerControl __instance)
{
if (Options.CurrentGameMode != CustomGameMode.HotPotato || !Main.IntroDestroyed || !AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || __instance.PlayerId >= 254 || Utils.GameStartTimeStamp + 15 > Utils.TimeStamp) return;
if (Options.CurrentGameMode != CustomGameMode.HotPotato || !Main.IntroDestroyed || !AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || __instance.PlayerId >= 254 || IntroCutsceneDestroyPatch.IntroDestroyTS + 5 > Utils.TimeStamp) return;
PlayerControl holder = Utils.GetPlayerById(HotPotatoState.HolderID);
+3 -6
View File
@@ -26,7 +26,6 @@ public static class NaturalDisasters
public static readonly Dictionary<byte, int> SurvivalTimes = [];
private static ((float Left, float Right) X, (float Bottom, float Top) Y) MapBounds;
private static long GameStartTimeStamp;
private static OptionItem DisasterFrequency;
private static OptionItem DisasterWarningTime;
@@ -132,8 +131,6 @@ public static class NaturalDisasters
const float extend = 5f;
MapBounds = ((x.Min() - extend, x.Max() + extend), (y.Min() - extend, y.Max() + extend));
GameStartTimeStamp = Utils.TimeStamp;
LateTask.New(() =>
{
Main.AllPlayerSpeed = Main.PlayerStates.Keys.ToDictionary(k => k, _ => Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod));
@@ -160,7 +157,7 @@ public static class NaturalDisasters
public static void RecordDeath(PlayerControl pc, PlayerState.DeathReason deathReason)
{
SurvivalTimes[pc.PlayerId] = (int)(Utils.TimeStamp - GameStartTimeStamp - 15);
SurvivalTimes[pc.PlayerId] = (int)(Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS);
string message = Translator.GetString($"ND_DRLaughMessage.{deathReason}");
message = Utils.ColorString(DeathReasonColor(deathReason), message);
@@ -205,7 +202,7 @@ public static class NaturalDisasters
public static void Postfix( /*PlayerControl __instance*/)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || (Options.CurrentGameMode != CustomGameMode.NaturalDisasters && !Options.IntegrateNaturalDisasters.GetBool()) || !Main.IntroDestroyed || Main.HasJustStarted || GameStartTimeStamp + 15 > Utils.TimeStamp /* || __instance.PlayerId >= 254 || !__instance.IsHost()*/) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || (Options.CurrentGameMode != CustomGameMode.NaturalDisasters && !Options.IntegrateNaturalDisasters.GetBool()) || !Main.IntroDestroyed || Main.HasJustStarted || IntroCutsceneDestroyPatch.IntroDestroyTS + 5 > Utils.TimeStamp /* || __instance.PlayerId >= 254 || !__instance.IsHost()*/) return;
if (Options.CurrentGameMode != CustomGameMode.NaturalDisasters)
{
@@ -220,7 +217,7 @@ public static class NaturalDisasters
_ => (0, false)
};
if (shouldWait || GameStartTimeStamp + minimumWaitTime > Utils.TimeStamp) return;
if (shouldWait || IntroCutsceneDestroyPatch.IntroDestroyTS + minimumWaitTime > Utils.TimeStamp) return;
}
UpdatePreparingDisasters();
+33 -1
View File
@@ -5,6 +5,7 @@ using AmongUs.InnerNet.GameDataMessages;
using EHR.Crewmate;
using EHR.Impostor;
using EHR.Modules;
using HarmonyLib;
using Hazel;
using InnerNet;
using UnityEngine;
@@ -77,6 +78,9 @@ namespace EHR
sender.EndMessage();
sender.SendMessage();
playerControl.transform.FindChild("Names").FindChild("NameText_TMP").gameObject.SetActive(true);
LateTask.New(() => Utils.SendRPC(CustomRPC.FixModdedClientCNO, playerControl, true), 0.3f);
}
public void TP(Vector2 position)
@@ -168,7 +172,7 @@ namespace EHR
Logger.Info($" Create Custom Net Object {GetType().Name} (ID {MaxId + 1}) at {position} - Time since game start: {Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS}s", "CNO.CreateNetObject");
if (!GameStates.InGame || !Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10)
if (Options.CurrentGameMode == CustomGameMode.Standard && (!GameStates.InGame || !Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10))
{
if (GameStates.InGame && (!Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10))
{
@@ -673,7 +677,15 @@ namespace EHR
protected override void OnFixedUpdate()
{
base.OnFixedUpdate();
int oldTime = Time;
if (oldTime <= 0)
{
Despawn();
return;
}
Timer -= UnityEngine.Time.fixedDeltaTime;
if (Time != oldTime) RpcChangeSprite($"<size=250%>{Time:N0}</size>\n{Disaster}");
}
@@ -966,4 +978,24 @@ namespace EHR
Active = true;
}
}
}
// This method sometimes throws an exception, preventing further code from running
// Fixed by wrapping each line in try-catch
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RawSetName))]
static class RawSetNameErrorFixPatch
{
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] string name)
{
try { __instance.gameObject.name = name; }
catch { }
try { __instance.cosmetics.SetName(name); }
catch { }
try { __instance.cosmetics.SetNameMask(true); }
catch { }
return false;
}
}
+1 -1
View File
@@ -133,7 +133,7 @@ public static class Statistics
if (addons.Contains(CustomRoles.Spurt) && Spurt.LocalPlayerAvoidsZeroAndOneHundredPrecent)
Achievements.Type.ExpertControl.CompleteAfterGameEnd();
if (Utils.GameStartTimeStamp + 90 > Utils.TimeStamp)
if (IntroCutsceneDestroyPatch.IntroDestroyTS + 60 > Utils.TimeStamp)
Achievements.Type.Speedrun.CompleteAfterGameEnd();
if (won && CustomWinnerHolder.WinnerTeam == CustomWinner.Impostor && lp.IsMadmate() && !aapc.Any(x => x.IsImpostor()))
+3 -3
View File
@@ -2363,7 +2363,7 @@ public static class Utils
longInfo = $"<#ffffff>{longInfo}</color>";
int lines = longInfo.Count(x => x == '\n');
int readTime = 20 + (lines * 5);
int readTime = 10 + (lines * 5);
LongRoleDescriptions[seer.PlayerId] = (longInfo, readTime, tooLong);
}
@@ -2678,11 +2678,11 @@ public static class Utils
}
else if (Options.CurrentGameMode == CustomGameMode.HideAndSeek)
{
if (GameStartTimeStamp + 40 > now) seerRealName = CustomHnS.GetRoleInfoText(seer);
if (IntroCutsceneDestroyPatch.IntroDestroyTS + 15 > now) seerRealName = CustomHnS.GetRoleInfoText(seer);
}
else if (Options.ChangeNameToRoleInfo.GetBool() && !seer.IsModdedClient() && Options.CurrentGameMode == CustomGameMode.Standard)
{
bool showLongInfo = LongRoleDescriptions.TryGetValue(seer.PlayerId, out (string Text, int Duration, bool Long) description) && GameStartTimeStamp + description.Duration > now;
bool showLongInfo = LongRoleDescriptions.TryGetValue(seer.PlayerId, out (string Text, int Duration, bool Long) description) && IntroCutsceneDestroyPatch.IntroDestroyTS + description.Duration > now;
string mHelp = !showLongInfo || description.Long ? "\n" + GetString("MyRoleCommandHelp") : string.Empty;
string color = seerTeam.GetTextColor();
string teamStr = seerTeam == Team.Impostor && seer.IsMadmate() ? "Madmate" : seerTeam.ToString();
+2 -2
View File
@@ -1564,8 +1564,8 @@ internal static class FixedUpdatePatch
if (self)
{
if (QuizMaster.On && inTask && !lowLoad && QuizMaster.AllSabotages.Any(IsActive))
QuizMaster.Data.LastSabotage = QuizMaster.AllSabotages.FirstOrDefault(IsActive);
if (QuizMaster.On && inTask && !lowLoad && QuizMaster.AllSabotages.FindFirst(IsActive, out SystemTypes active))
QuizMaster.Data.LastSabotage = active;
}
if (!lowLoad && player.IsModdedClient() && player.Is(CustomRoles.Haste))
+3
View File
@@ -338,6 +338,9 @@ internal class Adventurer : RoleBase
public override void AfterMeetingTasks()
{
long now = Utils.TimeStamp;
LastGroupingResourceTimeStamp = now;
LastRandomResourceTimeStamp = now;
ActiveWeapons.Remove(Weapon.Proxy);
}
+9
View File
@@ -97,6 +97,14 @@ public class Abyssbringer : RoleBase
Main.AllPlayerKillCooldown[id] = KillCooldown.GetInt();
}
public override void OnMurder(PlayerControl killer, PlayerControl target)
{
if (Options.UsePets.GetBool() && !Options.UsePhantomBasis.GetBool())
killer.AddAbilityCD();
else
killer.RpcResetAbilityCooldown();
}
public override bool OnShapeshift(PlayerControl shapeshifter, PlayerControl target, bool shapeshifting)
{
if (!shapeshifting) return true;
@@ -123,6 +131,7 @@ public class Abyssbringer : RoleBase
string roomName = room == null ? string.Empty : Translator.GetString($"{room.RoomId}");
BlackHoles.Add(new(new(pos), Utils.TimeStamp, pos, roomName, 0));
Utils.SendRPC(CustomRPC.SyncRoleData, AbyssbringerId, 1, pos, roomName);
shapeshifter.SetKillCooldown(KillCooldown.GetInt());
}
public override void OnReportDeadBody()