reduce cno delay & altruist prevents game end during revival

This commit is contained in:
Gurge44 committed 2025-12-16 09:21:14 +01:00
1 parent e30afe2b02
commit b0e39574f4
32 files changed
+188 -42

No files matched your search

+4
View File
@@ -161,6 +161,7 @@ public enum CustomRoles
Battery,
Beacon,
Benefactor,
Bestower,
Bodyguard,
CameraMan,
Captain,
@@ -375,7 +376,9 @@ public enum CustomRoles
Sidekick,
Simon,
Slenderman,
SoulCollector,
SoulHunter,
Spider,
Spirit,
Spiritcaller,
Sprayer,
@@ -414,6 +417,7 @@ public enum CustomRoles
Enchanter,
Goddess,
Illusionist,
MoonDancer,
Poache,
PotionMaster,
Reaper,
+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>
+4 -4
View File
@@ -166,18 +166,18 @@ namespace EHR
{
if (GameStates.IsEnded || !AmongUsClient.Instance.AmHost) return;
Logger.Info($" Create Custom Net Object {GetType().Name} (ID {MaxId + 1}) at {position} - Time since game start: {Utils.TimeStamp - Utils.GameStartTimeStamp}s", "CNO.CreateNetObject");
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 - Utils.GameStartTimeStamp < 40)
if (!GameStates.InGame || !Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10)
{
if (GameStates.InGame && (!Main.IntroDestroyed || Utils.TimeStamp - Utils.GameStartTimeStamp < 40))
if (GameStates.InGame && (!Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10))
{
Main.Instance.StartCoroutine(CoRoutine());
System.Collections.IEnumerator CoRoutine()
{
Logger.Info("Delaying CNO Spawn", "CustomNetObject.CreateNetObject");
while (GameStates.InGame && !GameStates.IsEnded && (!Main.IntroDestroyed || Utils.TimeStamp - Utils.GameStartTimeStamp < 40)) yield return null;
while (GameStates.InGame && !GameStates.IsEnded && (!Main.IntroDestroyed || Utils.TimeStamp - IntroCutsceneDestroyPatch.IntroDestroyTS < 10)) yield return null;
yield return new WaitForSeconds(3f);
if (!GameStates.InGame || GameStates.IsEnded || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks) yield break;
CreateNetObject(sprite, position);
+4 -4
View File
@@ -626,18 +626,18 @@ internal static class RPCHandlerPatch
case CustomRPC.NotificationPopper:
{
byte typeId = reader.ReadByte();
int item = reader.ReadPackedInt32();
int index = reader.ReadPackedInt32();
int customRole = reader.ReadPackedInt32();
bool playSound = reader.ReadBoolean();
OptionItem key = OptionItem.AllOptions[item];
OptionItem key = OptionItem.FastOptions[index];
switch (typeId)
{
case 0:
NotificationPopperPatch.AddSettingsChangeMessage(item, key, playSound);
NotificationPopperPatch.AddSettingsChangeMessage(index, key, playSound);
break;
case 1:
NotificationPopperPatch.AddRoleSettingsChangeMessage(item, key, (CustomRoles)customRole, playSound);
NotificationPopperPatch.AddRoleSettingsChangeMessage(index, key, (CustomRoles)customRole, playSound);
break;
}
+1 -1
View File
@@ -617,7 +617,7 @@ internal static class GameEndChecker
foreach (PlayerState playerState in statesCoutingAsCrew)
{
if (playerState.IsDead || !Options.CrewAdvancedGameEndCheckingSettings.TryGetValue(playerState.MainRole, out var option) || !option.GetBool()) continue;
playerState.Role.ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs);
playerState.Role.ManipulateGameEndCheckCrew(playerState, out bool keepGameGoing, out int countsAs);
crewKeepsGameGoing |= keepGameGoing;
crew += countsAs - 1;
}
+4
View File
@@ -1117,10 +1117,14 @@ internal static class BeginImpostorPatch
internal static class IntroCutsceneDestroyPatch
{
public static bool PreventKill;
public static long IntroDestroyTS;
public static void Postfix( /*IntroCutscene __instance*/)
{
if (!GameStates.IsInGame) return;
IntroDestroyTS = Utils.TimeStamp;
Main.IntroDestroyed = true;
PreventKill = true;
LateTask.New(() => PreventKill = false, 10f, "PreventKillReset");
+1 -2
View File
@@ -72,8 +72,7 @@ internal static class NotificationPopperPatch
private static void SendRpc(byte typeId, int index, CustomRoles customRole = CustomRoles.NotAssigned, bool playSound = true)
{
if (Options.HideGameSettings.GetBool()) return;
if (!AmongUsClient.Instance.AmHost || Options.HideGameSettings.GetBool()) return;
Utils.SendRPC(CustomRPC.NotificationPopper, typeId, index, (int)customRole, playSound);
}
}
+7 -1
View File
@@ -442,8 +442,14 @@ internal class Adventurer : RoleBase
return finalText;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+11 -5
View File
@@ -70,6 +70,11 @@ public class Altruist : RoleBase
{
if (!RevivingMode || target.Disconnected || target.Object.IsAlive() || target.Object.Is(CustomRoles.Disregarded)) return true;
RevivingMode = false;
ReviveTarget = target.PlayerId;
ReviveStartTS = Utils.TimeStamp;
ReviveTargetPos = reporter.Pos();
PlayerState state = Main.PlayerStates[reporter.PlayerId];
state.deathReason = PlayerState.DeathReason.Sacrifice;
state.RealKiller = (DateTime.Now, target.PlayerId);
@@ -77,11 +82,6 @@ public class Altruist : RoleBase
reporter.RpcExileV2();
Utils.AfterPlayerDeathTasks(reporter);
RevivingMode = false;
ReviveTarget = target.PlayerId;
ReviveStartTS = Utils.TimeStamp;
ReviveTargetPos = reporter.Pos();
return false;
}
@@ -166,4 +166,10 @@ public class Altruist : RoleBase
{
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
keepGameGoing = ReviveStartTS != 0;
countsAs = 1;
}
}
+7 -1
View File
@@ -85,8 +85,14 @@ public class Crusader : RoleBase
return false;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = false;
countsAs = 2;
}
+7 -1
View File
@@ -473,8 +473,14 @@ public class Dad : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -154,8 +154,14 @@ public class Decryptor : RoleBase
};
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = GuessMode.GetValue() == 2;
countsAs = 1;
}
+7 -1
View File
@@ -18,8 +18,14 @@ internal class Dictator : RoleBase
public override void Add(byte playerId) { }
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -128,8 +128,14 @@ public class Drainer : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -116,8 +116,14 @@ public class Imitator : RoleBase
}
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -2
View File
@@ -324,10 +324,15 @@ public class Judge : RoleBase
}
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
}
+7 -1
View File
@@ -142,8 +142,14 @@ internal class Mayor : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = false;
countsAs = 1 + MayorAdditionalVote.GetInt() + TaskVotes;
}
+7 -1
View File
@@ -169,8 +169,14 @@ public class Negotiator : RoleBase
LowSpeed
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -30,8 +30,14 @@ internal class NiceGuesser : RoleBase
public override void Add(byte playerId) { }
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -795,8 +795,14 @@ internal class Randomizer : RoleBase
catch (Exception ex) { Logger.Exception(ex, "Randomizer"); }
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -163,8 +163,14 @@ public class Retributionist : RoleBase
}
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = GameStates.IsInTask || Notified;
countsAs = 1;
}
+7 -1
View File
@@ -220,8 +220,14 @@ internal class Sentinel : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -186,8 +186,14 @@ public class Sheriff : RoleBase
return ShowShotLimit.GetBool() ? base.GetProgressText(playerId, comms) : Utils.GetTaskCount(playerId, comms);
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -92,8 +92,14 @@ internal class Speedrunner : RoleBase
return string.Format(notifyString, speedrunnerName, ts.RemainingTasksCount);
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -334,8 +334,14 @@ public class Swapper : RoleBase
}
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -226,8 +226,14 @@ public class Telekinetic : RoleBase
Doors
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -233,8 +233,14 @@ internal class TimeMaster : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = false;
countsAs = 1;
int length = TimeMasterRewindTimeLength.GetInt();
+7 -1
View File
@@ -174,8 +174,14 @@ internal class Tornado : RoleBase
return string.Join(hud ? "\n" : ", ", Tornados.Select(x => $"Tornado {GetFormattedRoomName(x.Key.RoomName)} {GetFormattedVectorText(x.Key.Location)} ({(int)(TornadoDuration.GetInt() - (TimeStamp - x.Value) + 1)}s)"));
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -156,8 +156,14 @@ internal class Veteran : RoleBase
return !IsThisRole(pc) || pc.Is(CustomRoles.Nimble) || pc.GetClosestVent()?.Id == ventId;
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = true;
countsAs = 1;
}
+7 -1
View File
@@ -111,8 +111,14 @@ public class Vigilante : RoleBase
}, 0.2f, log: false);
}
public override void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public override void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
if (playerState.IsDead)
{
base.ManipulateGameEndCheckCrew(playerState, out keepGameGoing, out countsAs);
return;
}
keepGameGoing = PlayerIdList.Exists(x => !Killed.Contains(x));
countsAs = 1;
}
+2
View File
@@ -121,6 +121,8 @@ public class PlagueBearer : RoleBase
{
if (IsPlagued(killer.PlayerId, target.PlayerId))
{
killer.ResetKillCooldown();
killer.SetKillCooldown(PlagueBearerCDOpt.GetFloat());
killer.Notify(GetString("PlagueBearerAlreadyPlagued"));
return false;
}
+1 -1
View File
@@ -196,7 +196,7 @@ public abstract class RoleBase : IComparable<RoleBase>
return seerRole.IsNK() && seerRole == target.GetCustomRole() && seer.GetTeam() == target.GetTeam();
}
public virtual void ManipulateGameEndCheckCrew(out bool keepGameGoing, out int countsAs)
public virtual void ManipulateGameEndCheckCrew(PlayerState playerState, out bool keepGameGoing, out int countsAs)
{
keepGameGoing = false;
countsAs = 1;