mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-11-19 13:16:56 +00:00
some fixes and improvements (+spread out per-second updates between frames)
This commit is contained in:
1 parent
d0b9f6c261
commit
7e79a2d6f9
38 files changed
+281
-276
No files matched your search
@@ -96,7 +96,7 @@ internal static class HotPotato
|
||||
|
||||
public static string GetSuffixText(byte id, bool hud)
|
||||
{
|
||||
if (!Main.PlayerStates.TryGetValue(id, out PlayerState state) || (id.IsPlayerModdedClient() && !hud) || state.IsDead) return string.Empty;
|
||||
if (!Main.PlayerStates.TryGetValue(id, out PlayerState state) || (id.IsPlayerModdedClient() && !hud) || (state.IsDead && !hud)) return string.Empty;
|
||||
string holding = HotPotatoState.HolderID == id ? $"{Translator.GetString("HotPotato_HoldingNotify")}\n" : string.Empty;
|
||||
string arrows = TargetArrow.GetAllArrows(id);
|
||||
arrows = arrows.Length > 0 ? $"\n{arrows}" : string.Empty;
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace EHR
|
||||
public static readonly List<CustomNetObject> AllObjects = [];
|
||||
private static int MaxId = -1;
|
||||
|
||||
protected virtual bool ConstantlyChangesPosition => false;
|
||||
|
||||
protected int Id;
|
||||
public PlayerControl playerControl;
|
||||
public Vector2 Position;
|
||||
@@ -94,7 +96,6 @@ namespace EHR
|
||||
public void TP(Vector2 position)
|
||||
{
|
||||
Position = position;
|
||||
SnapToSendFrameCount = 30;
|
||||
}
|
||||
|
||||
private bool TryReusePooledObject(string sprite, Vector2 position)
|
||||
@@ -241,8 +242,20 @@ namespace EHR
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
// max 30 calls per second in total
|
||||
if (++SnapToSendFrameCount < Math.Max(10, AllObjects.Count)) return;
|
||||
// max ~60 calls per second in total
|
||||
int updateFrequency;
|
||||
|
||||
if (!ConstantlyChangesPosition)
|
||||
{
|
||||
updateFrequency = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
(int trueCount, int falseCount) = AllObjects.SplitCount(x => x.ConstantlyChangesPosition);
|
||||
updateFrequency = trueCount / 2 + falseCount;
|
||||
}
|
||||
|
||||
if (++SnapToSendFrameCount < updateFrequency) return;
|
||||
SnapToSendFrameCount = 0;
|
||||
|
||||
if (AmongUsClient.Instance.AmClient)
|
||||
@@ -595,6 +608,8 @@ namespace EHR
|
||||
if (Abyssbringer.ShouldDespawnCNOOnMeeting) Despawn();
|
||||
else base.OnMeeting();
|
||||
}
|
||||
|
||||
protected override bool ConstantlyChangesPosition => Abyssbringer.BlackHoleMovesTowardsNearestPlayer.GetBool();
|
||||
}
|
||||
|
||||
internal sealed class SprayedArea : CustomNetObject
|
||||
@@ -673,6 +688,8 @@ namespace EHR
|
||||
CreateNetObject(warning, position);
|
||||
}
|
||||
|
||||
protected override bool ConstantlyChangesPosition => !SpawnTimer.IsRunning && DisasterName is "Tsunami" or "Tornado";
|
||||
|
||||
public SystemTypes? Room { get; }
|
||||
public string DisasterName { get; }
|
||||
public Stopwatch SpawnTimer { get; }
|
||||
@@ -919,6 +936,8 @@ namespace EHR
|
||||
private Vector2 Direction;
|
||||
public bool Active;
|
||||
|
||||
protected override bool ConstantlyChangesPosition => Active;
|
||||
|
||||
public Snowball(Vector2 from, Vector2 direction, PlayerControl thrower)
|
||||
{
|
||||
Thrower = thrower;
|
||||
|
||||
@@ -189,6 +189,30 @@ public static class CollectionExtensions
|
||||
return (list1, list2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits a collection into two integers based on a predicate
|
||||
/// </summary>
|
||||
/// <param name="predicate">The predicate to split the collection by</param>
|
||||
/// <returns>
|
||||
/// A tuple containing two integers: one that is the number of elements that satisfy the predicate, and one that is the number of elements that
|
||||
/// do not
|
||||
/// </returns>
|
||||
public (int TrueCount, int FalseCount) SplitCount(Func<T, bool> predicate)
|
||||
{
|
||||
var int1 = 0;
|
||||
var int2 = 0;
|
||||
|
||||
foreach (T element in collection)
|
||||
{
|
||||
if (predicate(element))
|
||||
int1++;
|
||||
else
|
||||
int2++;
|
||||
}
|
||||
|
||||
return (int1, int2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a collection contains any elements that satisfy a predicate and returns the first element that
|
||||
/// satisfies the predicate
|
||||
|
||||
@@ -26,6 +26,8 @@ public static class FixedUpdateCaller
|
||||
{
|
||||
try
|
||||
{
|
||||
PerSecondUpdateScheduler.OnFixedUpdate();
|
||||
|
||||
AmongUsClient = AmongUsClient.Instance;
|
||||
LobbyBehaviour = LobbyBehaviour.Instance;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ public static class NameNotifyManager
|
||||
private static readonly List<KeyValuePair<string, long>> NameList = [];
|
||||
private static readonly Comparison<KeyValuePair<string, long>> CompareByValue = static (a, b) => a.Value.CompareTo(b.Value);
|
||||
private static readonly StringBuilder Sb = new();
|
||||
private static long LastUpdate;
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
@@ -59,12 +58,11 @@ public static class NameNotifyManager
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate()) return;
|
||||
if (Notifies.Count == 0) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now == LastUpdate) return;
|
||||
LastUpdate = now;
|
||||
|
||||
if (Notifies.Count == 0) return;
|
||||
|
||||
var notifyEnumerator = Notifies.GetEnumerator();
|
||||
while (notifyEnumerator.MoveNext())
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace EHR.Modules;
|
||||
|
||||
public static class PerSecondUpdateScheduler
|
||||
{
|
||||
private const int Slots = 30;
|
||||
|
||||
private static long FixedTick;
|
||||
|
||||
private static int CurrentSlot => (int)(FixedTick % Slots);
|
||||
|
||||
private struct Entry
|
||||
{
|
||||
public long LastSecond;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<int, Entry> State = new();
|
||||
|
||||
public static void OnFixedUpdate()
|
||||
{
|
||||
FixedTick++;
|
||||
}
|
||||
|
||||
public static bool ShouldRunUpdate(object identifier = null, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
|
||||
{
|
||||
long now = Utils.TimeStamp;
|
||||
int key = HashCode.Combine(file, line, identifier);
|
||||
|
||||
if (!State.TryGetValue(key, out var entry))
|
||||
entry.LastSecond = -1;
|
||||
|
||||
if (entry.LastSecond == now)
|
||||
return false;
|
||||
|
||||
int slot = (key & int.MaxValue) % Slots;
|
||||
|
||||
if (slot != CurrentSlot)
|
||||
return false;
|
||||
|
||||
entry.LastSecond = now;
|
||||
State[key] = entry;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
State.Clear();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -36,8 +36,8 @@ public static class Prompt
|
||||
|
||||
Action closePromt = () =>
|
||||
{
|
||||
HidePromt();
|
||||
CurrentQuestion = string.Empty;
|
||||
HidePromt();
|
||||
|
||||
if (!ShowBackButton) hud.Dialogue.BackButton.gameObject.SetActive(true);
|
||||
hud.Dialogue.Hide();
|
||||
@@ -97,9 +97,9 @@ public static class Prompt
|
||||
{
|
||||
if (!ShowBackButton) return false;
|
||||
|
||||
CurrentQuestion = string.Empty;
|
||||
ClearQueue();
|
||||
HidePromt();
|
||||
CurrentQuestion = string.Empty;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
+1
-2
@@ -1052,8 +1052,7 @@ internal static class RPCHandlerPatch
|
||||
byte id = reader.ReadByte();
|
||||
bool isRampaging = reader.ReadBoolean();
|
||||
int chargePercent = reader.ReadInt32();
|
||||
long lastUpdate = long.Parse(reader.ReadString());
|
||||
(Main.PlayerStates[id].Role as Chronomancer)?.ReceiveRPC(isRampaging, chargePercent, lastUpdate);
|
||||
(Main.PlayerStates[id].Role as Chronomancer)?.ReceiveRPC(isRampaging, chargePercent);
|
||||
break;
|
||||
}
|
||||
case CustomRPC.SetMedicalerProtectList:
|
||||
|
||||
+116
-135
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using static EHR.Translator;
|
||||
|
||||
namespace EHR;
|
||||
@@ -146,151 +147,131 @@ public static class SpamManager
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly string[] StartWords =
|
||||
[
|
||||
"start",
|
||||
"started",
|
||||
"begin",
|
||||
"commence",
|
||||
"proceed",
|
||||
|
||||
// Russian
|
||||
"старт",
|
||||
"начни",
|
||||
"начинай",
|
||||
"го",
|
||||
"гоу",
|
||||
|
||||
// Chinese
|
||||
"开",
|
||||
"开始",
|
||||
"快开",
|
||||
|
||||
// Pinyin
|
||||
"kai",
|
||||
"kaishi"
|
||||
];
|
||||
|
||||
private static bool ContainsStart(string text)
|
||||
{
|
||||
text = text.Trim().ToLower();
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return false;
|
||||
|
||||
var stNum = 0;
|
||||
if (text.Length > 35)
|
||||
return false;
|
||||
|
||||
for (var i = 0; i < text.Length; i++)
|
||||
string normalized = Normalize(text);
|
||||
|
||||
foreach (string word in StartWords)
|
||||
{
|
||||
if (text[i..].Equals("k")) stNum++;
|
||||
if (text[i..].Equals("开")) stNum++;
|
||||
}
|
||||
string target = Normalize(word);
|
||||
|
||||
if (stNum >= 3) return true;
|
||||
|
||||
switch (text)
|
||||
{
|
||||
case "Start":
|
||||
case "start":
|
||||
case "/Start":
|
||||
case "/Start/":
|
||||
case "Start/":
|
||||
case "/start":
|
||||
case "/start/":
|
||||
case "start/":
|
||||
case "plsstart":
|
||||
case "pls start":
|
||||
case "please start":
|
||||
case "pleasestart":
|
||||
case "Plsstart":
|
||||
case "Pls start":
|
||||
case "Please start":
|
||||
case "Pleasestart":
|
||||
case "plsStart":
|
||||
case "pls Start":
|
||||
case "please Start":
|
||||
case "pleaseStart":
|
||||
case "PlsStart":
|
||||
case "Pls Start":
|
||||
case "Please Start":
|
||||
case "PleaseStart":
|
||||
case "sTart":
|
||||
case "stArt":
|
||||
case "staRt":
|
||||
case "starT":
|
||||
case "s t a r t":
|
||||
case "S t a r t":
|
||||
case "started":
|
||||
case "Started":
|
||||
case "s t a r t e d":
|
||||
case "S t a r t e d":
|
||||
case "Го":
|
||||
case "гО":
|
||||
case "го":
|
||||
case "Гоу":
|
||||
case "гоу":
|
||||
case "Старт":
|
||||
case "старт":
|
||||
case "/Старт":
|
||||
case "/Старт/":
|
||||
case "Старт/":
|
||||
case "/старт":
|
||||
case "/старт/":
|
||||
case "старт/":
|
||||
case "пжстарт":
|
||||
case "пж старт":
|
||||
case "пжСтарт":
|
||||
case "пж Старт":
|
||||
case "Пжстарт":
|
||||
case "Пж старт":
|
||||
case "ПжСтарт":
|
||||
case "Пж Старт":
|
||||
case "сТарт":
|
||||
case "стАрт":
|
||||
case "стаРт":
|
||||
case "старТ":
|
||||
case "с т а р т":
|
||||
case "С т а р т":
|
||||
case "начни":
|
||||
case "Начни":
|
||||
case "начинай":
|
||||
case "начинай уже":
|
||||
case "Начинай":
|
||||
case "Начинай уже":
|
||||
case "Начинай Уже":
|
||||
case "н а ч и н а й":
|
||||
case "Н а ч и н а й":
|
||||
case "пж го":
|
||||
case "пжго":
|
||||
case "Пж Го":
|
||||
case "Пж го":
|
||||
case "пж Го":
|
||||
case "ПжГо":
|
||||
case "Пжго":
|
||||
case "пжГо":
|
||||
case "ГоПж":
|
||||
case "гоПж":
|
||||
case "Гопж":
|
||||
case "开":
|
||||
case "快开":
|
||||
case "开始":
|
||||
case "开啊":
|
||||
case "开阿":
|
||||
case "kai":
|
||||
case "kaishi":
|
||||
if (normalized.Contains(target))
|
||||
return true;
|
||||
|
||||
// Fuzzy matching
|
||||
if (LevenshteinDistance(normalized, target) <= 1)
|
||||
return true;
|
||||
|
||||
// Check every substring of similar length
|
||||
for (int i = 0; i < normalized.Length; i++)
|
||||
{
|
||||
int len = Math.Min(target.Length + 2, normalized.Length - i);
|
||||
|
||||
for (int j = Math.Max(1, target.Length - 2); j <= len; j++)
|
||||
{
|
||||
string part = normalized.Substring(i, j);
|
||||
|
||||
if (LevenshteinDistance(part, target) <= 1)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text.Length > 30) return false;
|
||||
// Chinese "开开开"
|
||||
return normalized.Count(c => c == '开') >= 3;
|
||||
}
|
||||
|
||||
private static string Normalize(string text)
|
||||
{
|
||||
text = text.ToLowerInvariant();
|
||||
|
||||
if (text.Contains("start")) return true;
|
||||
if (text.Contains("Start")) return true;
|
||||
if (text.Contains("STart")) return true;
|
||||
if (text.Contains("s t a r t")) return true;
|
||||
if (text.Contains("begin")) return true;
|
||||
if (text.Contains("commence")) return true;
|
||||
if (text.Contains('了')) return false;
|
||||
if (text.Contains('没')) return false;
|
||||
if (text.Contains('吗')) return false;
|
||||
if (text.Contains('哈')) return false;
|
||||
if (text.Contains('还')) return false;
|
||||
if (text.Contains('现')) return false;
|
||||
if (text.Contains('不')) return false;
|
||||
if (text.Contains('可')) return false;
|
||||
if (text.Contains('刚')) return false;
|
||||
if (text.Contains('的')) return false;
|
||||
if (text.Contains('打')) return false;
|
||||
if (text.Contains('门')) return false;
|
||||
if (text.Contains('关')) return false;
|
||||
if (text.Contains('怎')) return false;
|
||||
if (text.Contains('要')) return false;
|
||||
if (text.Contains('摆')) return false;
|
||||
if (text.Contains('啦')) return false;
|
||||
if (text.Contains('咯')) return false;
|
||||
if (text.Contains('嘞')) return false;
|
||||
if (text.Contains('勒')) return false;
|
||||
if (text.Contains('心')) return false;
|
||||
if (text.Contains('呢')) return false;
|
||||
if (text.Contains('门')) return false;
|
||||
if (text.Contains('总')) return false;
|
||||
if (text.Contains('哥')) return false;
|
||||
if (text.Contains('姐')) return false;
|
||||
if (text.Contains('《')) return false;
|
||||
if (text.Contains('?')) return false;
|
||||
if (text.Contains('?')) return false;
|
||||
return text.Contains('开') || text.Contains("kai");
|
||||
text = text.Normalize(NormalizationForm.FormD);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (char c in text)
|
||||
{
|
||||
var category = CharUnicodeInfo.GetUnicodeCategory(c);
|
||||
|
||||
if (category == UnicodeCategory.NonSpacingMark)
|
||||
continue;
|
||||
|
||||
sb.Append(c);
|
||||
}
|
||||
|
||||
text = sb.ToString();
|
||||
|
||||
// Common leetspeak replacements
|
||||
text = text
|
||||
.Replace('0', 'o')
|
||||
.Replace('1', 'i')
|
||||
.Replace('3', 'e')
|
||||
.Replace('4', 'a')
|
||||
.Replace('5', 's')
|
||||
.Replace('7', 't');
|
||||
|
||||
// Remove everything except letters/numbers/CJK
|
||||
text = Regex.Replace(text, @"[\W_]+", "");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private static int LevenshteinDistance(string s, string t)
|
||||
{
|
||||
int[,] d = new int[s.Length + 1, t.Length + 1];
|
||||
|
||||
for (int i = 0; i <= s.Length; i++)
|
||||
d[i, 0] = i;
|
||||
|
||||
for (int j = 0; j <= t.Length; j++)
|
||||
d[0, j] = j;
|
||||
|
||||
for (int i = 1; i <= s.Length; i++)
|
||||
{
|
||||
for (int j = 1; j <= t.Length; j++)
|
||||
{
|
||||
int cost = s[i - 1] == t[j - 1] ? 0 : 1;
|
||||
|
||||
d[i, j] = Math.Min(
|
||||
Math.Min(
|
||||
d[i - 1, j] + 1,
|
||||
d[i, j - 1] + 1),
|
||||
d[i - 1, j - 1] + cost);
|
||||
}
|
||||
}
|
||||
|
||||
return d[s.Length, t.Length];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1104,7 +1104,7 @@ public static class Utils
|
||||
try
|
||||
{
|
||||
float limit = playerId.GetAbilityUseLimit();
|
||||
if (float.IsNaN(limit) || limit >= 10) return string.Empty;
|
||||
if (float.IsNaN(limit) || (limit >= 10 && (!Main.PlayerStates.TryGetValue(playerId, out var state) || state.MainRole != CustomRoles.Generator))) return string.Empty;
|
||||
|
||||
Color textColor;
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ internal static class GameEndChecker
|
||||
if (Predicate == null || ShouldNotCheck || !AmongUsClient.Instance.AmHost || Main.HasJustStarted) return;
|
||||
if (Options.NoGameEnd.GetBool() && WinnerTeam is not CustomWinner.Draw and not CustomWinner.Error) return;
|
||||
|
||||
if (LastGameEndCheckUpdated != -1 && !PerSecondUpdateScheduler.ShouldRunUpdate()) return;
|
||||
var now = TimeStamp;
|
||||
if (LastGameEndCheckUpdated == now) return;
|
||||
LastGameEndCheckUpdated = now;
|
||||
Ended = false;
|
||||
|
||||
|
||||
@@ -47,9 +47,7 @@ internal static class PingTrackerUpdatePatch
|
||||
|
||||
if (!Instance) Instance = __instance;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now == LastUpdate) return false;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate()) return false;
|
||||
|
||||
bool inGame = GameStates.InGame;
|
||||
Sb.Clear()
|
||||
|
||||
@@ -433,6 +433,7 @@ internal static class ChangeRoleSettings
|
||||
GhostRolesManager.Initialize();
|
||||
RoleBlockManager.Reset();
|
||||
ChatManager.ResetHistory();
|
||||
PerSecondUpdateScheduler.Reset();
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ internal static class EndGamePatch
|
||||
Main.LoversPlayers.Clear();
|
||||
Bloodmoon.OnMeetingStart();
|
||||
AFKDetector.ExemptedPlayers.Clear();
|
||||
PerSecondUpdateScheduler.Reset();
|
||||
|
||||
foreach (PlayerState state in Main.PlayerStates.Values)
|
||||
state.Role.Init();
|
||||
|
||||
@@ -1551,7 +1551,6 @@ internal static class FixedUpdatePatch
|
||||
private static readonly Dictionary<byte, long> LastAddAbilityTime = [];
|
||||
private static readonly List<string> AdditionalSuffixes = [];
|
||||
private static long LastErrorTS;
|
||||
private static long LastSelfNameUpdateTS;
|
||||
|
||||
public static void Postfix(PlayerControl __instance, bool lowLoad)
|
||||
{
|
||||
@@ -1586,8 +1585,8 @@ internal static class FixedUpdatePatch
|
||||
case Haunter haunter:
|
||||
haunter.Update(__instance);
|
||||
break;
|
||||
case Bloodmoon bloodmoon:
|
||||
Bloodmoon.Update(__instance, bloodmoon);
|
||||
case Bloodmoon:
|
||||
Bloodmoon.Update(__instance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1839,12 +1838,10 @@ internal static class FixedUpdatePatch
|
||||
|
||||
if (GameStates.IsEnded || !Main.IntroDestroyed || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks) return;
|
||||
|
||||
bool shouldUpdateRegardlessOfLowLoad = self && GameStates.InGame && PlayerControl.LocalPlayer.IsAlive() && ((PlayerControl.AllPlayerControls.Count > 30 && LastSelfNameUpdateTS != now && Options.CurrentGameMode is CustomGameMode.StopAndGo or CustomGameMode.HotPotato or CustomGameMode.Speedrun or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.Mingle) || DirtyName.Remove(lpId));
|
||||
bool shouldUpdateRegardlessOfLowLoad = self && GameStates.InGame && PlayerControl.LocalPlayer.IsAlive() && ((PlayerControl.AllPlayerControls.Count > 30 && PerSecondUpdateScheduler.ShouldRunUpdate() && Options.CurrentGameMode is CustomGameMode.StopAndGo or CustomGameMode.HotPotato or CustomGameMode.Speedrun or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.Mingle) || DirtyName.Remove(lpId));
|
||||
|
||||
if (lowLoad && !shouldUpdateRegardlessOfLowLoad) return;
|
||||
|
||||
if (self) LastSelfNameUpdateTS = now;
|
||||
|
||||
if (isLobby && !player.AmOwner)
|
||||
{
|
||||
if (Main.PlayerVersion.TryGetValue(playerId, out PlayerVersion ver))
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
"TrackerTitle": "★[ Track Reading ]★",
|
||||
"TrialKillTitle": "[★ Court ★]",
|
||||
"VirusNoticeTitle": "[ Infected Corpse! ]",
|
||||
"VotedToStart.Title": "<size=90%><#00a5ff>{0} voted to start the game using <#00ffff>/vs</color>!</color></size>",
|
||||
"VotedToStart.Title": "<size=80%><#00a5ff>{0} voted to start the game using <#00ffff>/vs</color>!</color></size>",
|
||||
"WhisperTitle": "{0} <#ffffff>(ID <#00ffa5>{1}</color>) whispers to you:</color>",
|
||||
"WinsCountTitle": "Number of wins in this game mode",
|
||||
"XORListTitle": "<#00a5ff>➡ XOR Combinations ⬅</color>",
|
||||
@@ -3436,7 +3436,7 @@
|
||||
"DreamweaverInfoLong": "(Coven):\\nWeave a player; woven players will become insane after the next meeting. Once insane, when they go near someone, they will immediately use their ability if their cooldown is up. Upon your death, all insane players will be freed. When enhanced by the Necronomicon, insane players will suicide after making contact with another player.",
|
||||
"Empress": "Empress",
|
||||
"EmpressInfo": "Empower the Necronomicon & Cast Spells",
|
||||
"EmpressInfoLong": "(Coven):\\nAs the Empress, you can vote yourself in a meeting to empower the Necronomicon. In the next round, Necronomicon holders can kill twice before their kill cooldown is reset, but their cooldown is doubled. The Necronomicon cannot be empowered in 2 consecutive rounds.\\n\\nThrough you kill button, you can also cast spells on players (they'll apply after a short delay):\\n- Frost gaze: Freezes its target in place, if they aren't interacted with in time they die instantly\\n- Encourage: Makes the target, if it's a coven member, 1.25x as fast and have their ability cooldown lowered by 25% for the round.\\nAfter you gain the Necronomicon, you can kill normally by double clicking your kill button on someone, and single clicking on them to cast the selected spell.\\nYou can change the selected spell by vanishing.\\n\\nBy petting, you can also turn yourself and neaby coven members invisible temporarily (has a delay).",
|
||||
"EmpressInfoLong": "(Coven):\\nAs the Empress, you can vote yourself in a meeting to empower the Necronomicon. In the next round, Necronomicon holders can kill twice before their kill cooldown is reset, but their cooldown is doubled. The Necronomicon cannot be empowered in 2 consecutive rounds.\\n\\nThrough you kill button, you can also cast spells on players (they'll apply after a short delay):\\n- Frost gaze: Freezes its target in place, if they aren't interacted with in time they die instantly\\n- Encourage: Makes the target, if it's a coven member, 1.25x as fast and have their ability cooldown lowered by 25% for the round.\\nAfter you gain the Necronomicon, you can kill normally by double clicking your kill button on someone, and single clicking on them to cast the selected spell.\\nYou can change the selected spell by vanishing.\\n\\nBy petting, you can also turn yourself and nearby coven members invisible temporarily (has a delay).",
|
||||
"Empress.CoverageDelay": "Coverage Delay",
|
||||
"Empress.CoverageDuration": "Coverage Duration",
|
||||
"Empress.CoverageRange": "Coverage Range",
|
||||
|
||||
@@ -10,7 +10,6 @@ public class Entombed : IAddon
|
||||
public AddonTypes Type => AddonTypes.Harmful;
|
||||
|
||||
public static Dictionary<byte, SystemTypes> BlockedRoom = [];
|
||||
private static long LastNotifyTS;
|
||||
private static long MeetingEndTS;
|
||||
private static float GracePeriodLength;
|
||||
|
||||
@@ -60,11 +59,8 @@ public class Entombed : IAddon
|
||||
|
||||
if (now - MeetingEndTS <= GracePeriodLength)
|
||||
{
|
||||
if (LastNotifyTS != now)
|
||||
{
|
||||
LastNotifyTS = now;
|
||||
if (PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId))
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public class Wyrd : CovenBase
|
||||
private static Dictionary<Action, bool> ActionSuicideSettings = [];
|
||||
|
||||
private int Countdown;
|
||||
private long LastUpdate;
|
||||
|
||||
public HashSet<byte> MarkedPlayers;
|
||||
private byte WyrdID;
|
||||
@@ -80,7 +79,6 @@ public class Wyrd : CovenBase
|
||||
Instances.Add(this);
|
||||
MarkedPlayers = [];
|
||||
Countdown = CountdownTime.GetInt();
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
}
|
||||
|
||||
public override void Remove(byte playerId)
|
||||
@@ -123,10 +121,7 @@ public class Wyrd : CovenBase
|
||||
}
|
||||
|
||||
if (MarkedPlayers.Count == 0 || Countdown <= 0) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate == now) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
Countdown--;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, WyrdID, 3, Countdown);
|
||||
|
||||
@@ -32,7 +32,6 @@ public class ToiletMaster : RoleBase
|
||||
private Dictionary<byte, (Poop Poop, long TimeStamp, object Data)> ActivePoops = [];
|
||||
|
||||
private static Poop[] AllPoopValues;
|
||||
private long LastUpdate;
|
||||
private List<PlayerControl> AffectedPlayers = [];
|
||||
private List<PlayerControl> ActivePoopDataList = [];
|
||||
private Dictionary<byte, long> PlayersUsingToilet = [];
|
||||
@@ -129,7 +128,6 @@ public class ToiletMaster : RoleBase
|
||||
{
|
||||
On = true;
|
||||
Instances.Add(this);
|
||||
LastUpdate = 8 + AbilityCooldown.GetInt() + ToiletDuration.GetInt();
|
||||
playerId.SetAbilityUseLimit(AbilityUses.GetFloat());
|
||||
}
|
||||
|
||||
@@ -310,11 +308,9 @@ public class ToiletMaster : RoleBase
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!pc.IsAlive() || !GameStates.IsInTask) return;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate >= now) return;
|
||||
LastUpdate = now;
|
||||
|
||||
int duration = ToiletDuration.GetInt();
|
||||
int maxUses = ToiletMaxUses.GetInt();
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ internal class Tornado : RoleBase
|
||||
|
||||
private static RandomSpawn.SpawnMap Map;
|
||||
private static readonly Dictionary<(Vector2 Location, string RoomName), long> Tornados = [];
|
||||
private static long LastNotify = TimeStamp;
|
||||
private static bool CanUseMap;
|
||||
private PlayerControl TornadoPC;
|
||||
private static int Id => 64420;
|
||||
@@ -52,7 +51,6 @@ internal class Tornado : RoleBase
|
||||
{
|
||||
PlayerIdList.Clear();
|
||||
Tornados.Clear();
|
||||
LastNotify = TimeStamp;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -160,10 +158,10 @@ internal class Tornado : RoleBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LastNotify >= now || pc.HasAbilityCD()) return;
|
||||
if (pc.HasAbilityCD()) return;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
LastNotify = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ internal class Adventurer : RoleBase
|
||||
private int Count;
|
||||
private bool InCraftingMode;
|
||||
private long LastGroupingResourceTimeStamp;
|
||||
|
||||
private long LastRandomResourceTimeStamp;
|
||||
|
||||
private List<Weapon> OrderedWeapons;
|
||||
@@ -276,7 +275,7 @@ internal class Adventurer : RoleBase
|
||||
|
||||
public override void OnGlobalFixedUpdate(PlayerControl pc, bool lowLoad)
|
||||
{
|
||||
if (lowLoad) return;
|
||||
if (lowLoad || !AdventurerPC || !AdventurerPC.IsAlive()) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
|
||||
@@ -339,8 +338,9 @@ internal class Adventurer : RoleBase
|
||||
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!pc.IsAlive()) return;
|
||||
|
||||
if (Count++ < 10) return;
|
||||
|
||||
Count = 0;
|
||||
|
||||
foreach ((Resource resource, Vector2 location) in ResourceLocations)
|
||||
|
||||
@@ -16,7 +16,6 @@ public class Oxyman : RoleBase
|
||||
private static OptionItem DecreasementEachSecond;
|
||||
private static OptionItem IncreasedSpeed;
|
||||
private static OptionItem DecreasedSpeed;
|
||||
private long LastUpdate;
|
||||
private int OxygenLevel;
|
||||
private byte OxymanId;
|
||||
|
||||
@@ -63,7 +62,6 @@ public class Oxyman : RoleBase
|
||||
On = true;
|
||||
OxymanId = playerId;
|
||||
OxygenLevel = 59;
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
}
|
||||
|
||||
public override void ApplyGameOptions(IGameOptions opt, byte playerId)
|
||||
@@ -89,10 +87,7 @@ public class Oxyman : RoleBase
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!pc.IsAlive() || !GameStates.IsInTask || ExileController.Instance || !Main.IntroDestroyed) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now == LastUpdate) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
if (OxygenLevel <= 0)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,6 @@ public class Telekinetic : RoleBase
|
||||
private static OptionItem IncreasedSpeed;
|
||||
|
||||
private Mode CurrentMode;
|
||||
private long LastUpdate;
|
||||
private bool Shielded;
|
||||
private PlayerControl TelekineticPC;
|
||||
private int Timer;
|
||||
@@ -69,11 +68,7 @@ public class Telekinetic : RoleBase
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!pc.IsAlive() || !GameStates.IsInTask || ExileController.Instance || Main.HasJustStarted) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now == LastUpdate) return;
|
||||
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
switch (Timer)
|
||||
{
|
||||
@@ -97,7 +92,7 @@ public class Telekinetic : RoleBase
|
||||
public override void OnPet(PlayerControl pc)
|
||||
{
|
||||
PlayerControl target = ExternalRpcPetPatch.SelectKillButtonTarget(pc);
|
||||
bool hasTarget = target != null;
|
||||
bool hasTarget = target;
|
||||
|
||||
switch (CurrentMode)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using Hazel;
|
||||
using EHR.Modules;
|
||||
|
||||
namespace EHR.Roles;
|
||||
|
||||
@@ -15,7 +15,6 @@ internal class Bloodmoon : IGhostRole
|
||||
|
||||
private static readonly Dictionary<byte, (long TimeStamp, byte KillerId)> ScheduledDeaths = [];
|
||||
|
||||
private long LastUpdate;
|
||||
private byte BloodmoonID;
|
||||
|
||||
public Team Team => Team.Impostor | Team.Neutral;
|
||||
@@ -26,7 +25,6 @@ internal class Bloodmoon : IGhostRole
|
||||
{
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = Speed.GetFloat();
|
||||
pc.MarkDirtySettings();
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
BloodmoonID = pc.PlayerId;
|
||||
}
|
||||
|
||||
@@ -50,7 +48,7 @@ internal class Bloodmoon : IGhostRole
|
||||
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Bloodmoon])
|
||||
.SetValueFormat(OptionFormat.Seconds);
|
||||
|
||||
Speed = new FloatOptionItem(649404, "Bloodmoon.Speed", new(0.05f, 3f, 0.05f), 0.5f, TabGroup.OtherRoles)
|
||||
Speed = new FloatOptionItem(649404, "Bloodmoon.Speed", new(0.05f, 3f, 0.05f), 0.25f, TabGroup.OtherRoles)
|
||||
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Bloodmoon])
|
||||
.SetValueFormat(OptionFormat.Multiplier);
|
||||
|
||||
@@ -62,13 +60,12 @@ internal class Bloodmoon : IGhostRole
|
||||
.SetValueFormat(OptionFormat.Seconds);
|
||||
}
|
||||
|
||||
public static void Update(PlayerControl pc, Bloodmoon instance)
|
||||
public static void Update(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks) return;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now == instance.LastUpdate) return;
|
||||
instance.LastUpdate = now;
|
||||
|
||||
foreach (KeyValuePair<byte, (long Value, byte KillerId)> death in ScheduledDeaths)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,7 @@ public class Ambusher : RoleBase
|
||||
DontCheck = false;
|
||||
}
|
||||
|
||||
if (LastRPCTS != now)
|
||||
if (LastRPCTS == 0 || PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId))
|
||||
{
|
||||
pc.RpcResetAbilityCooldown();
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, AmbusherId, 1, TargetId, TargetTimer, AbilityEndTimer, DontCheck);
|
||||
|
||||
@@ -26,7 +26,6 @@ public class Penguin : RoleBase
|
||||
private float DefaultSpeed;
|
||||
|
||||
private bool IsGoose;
|
||||
private long LastNotify;
|
||||
private bool MeetingKill;
|
||||
|
||||
private PlayerControl Penguin_;
|
||||
@@ -101,7 +100,6 @@ public class Penguin : RoleBase
|
||||
Penguin_ = Utils.GetPlayerById(playerId);
|
||||
|
||||
AbductTimer = null;
|
||||
LastNotify = 0;
|
||||
}
|
||||
|
||||
public override void SetKillCooldown(byte id)
|
||||
@@ -146,13 +144,11 @@ public class Penguin : RoleBase
|
||||
{
|
||||
AbductVictim = null;
|
||||
AbductTimer = null;
|
||||
Utils.SendRPC(CustomRPC.PenguinSync, PenguinId, 2, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AbductVictim = Utils.GetPlayerById(victim);
|
||||
AbductTimer = Stopwatch.StartNew();
|
||||
Utils.SendRPC(CustomRPC.PenguinSync, PenguinId, 2, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,11 +311,8 @@ public class Penguin : RoleBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (LastNotify != Utils.TimeStamp)
|
||||
{
|
||||
if (PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId))
|
||||
Utils.NotifyRoles(SpecifySeer: Penguin_, SpecifyTarget: Penguin_);
|
||||
LastNotify = Utils.TimeStamp;
|
||||
}
|
||||
|
||||
if (AbductTimer.Elapsed.TotalSeconds >= AbductTimerLimit && !Penguin_.MyPhysics.Animations.IsPlayingAnyLadderAnimation() && !Penguin_.inMovingPlat && !Penguin_.onLadder)
|
||||
{
|
||||
@@ -381,7 +374,7 @@ public class Penguin : RoleBase
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (AbductTimer != null)
|
||||
{
|
||||
AbductTimer = null;
|
||||
Utils.SendRPC(CustomRPC.PenguinSync, PenguinId, 2, true);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Abyssbringer : RoleBase
|
||||
public static OptionItem BlackHolePlaceCooldown;
|
||||
private static OptionItem BlackHoleDespawnMode;
|
||||
private static OptionItem BlackHoleDespawnTime;
|
||||
private static OptionItem BlackHoleMovesTowardsNearestPlayer;
|
||||
public static OptionItem BlackHoleMovesTowardsNearestPlayer;
|
||||
private static OptionItem BlackHoleMoveSpeed;
|
||||
private static OptionItem BlackHoleRadius;
|
||||
private static OptionItem KillCooldown;
|
||||
|
||||
@@ -18,7 +18,6 @@ public class Chronomancer : RoleBase
|
||||
private int ChargePercent;
|
||||
private byte ChronomancerId;
|
||||
private bool IsRampaging;
|
||||
private long LastUpdate;
|
||||
|
||||
public override bool IsEnable => PlayerIdList.Count > 0;
|
||||
|
||||
@@ -47,15 +46,13 @@ public class Chronomancer : RoleBase
|
||||
writer.Write(ChronomancerId);
|
||||
writer.Write(IsRampaging);
|
||||
writer.Write(ChargePercent);
|
||||
writer.Write(LastUpdate.ToString());
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
|
||||
public void ReceiveRPC(bool isRampaging, int chargePercent, long lastUpdate)
|
||||
public void ReceiveRPC(bool isRampaging, int chargePercent)
|
||||
{
|
||||
IsRampaging = isRampaging;
|
||||
ChargePercent = chargePercent;
|
||||
LastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
@@ -63,7 +60,6 @@ public class Chronomancer : RoleBase
|
||||
PlayerIdList = [];
|
||||
IsRampaging = false;
|
||||
ChargePercent = 0;
|
||||
LastUpdate = Utils.TimeStamp + 30;
|
||||
ChronomancerId = byte.MaxValue;
|
||||
}
|
||||
|
||||
@@ -73,7 +69,6 @@ public class Chronomancer : RoleBase
|
||||
RampageKills = 0;
|
||||
IsRampaging = false;
|
||||
ChargePercent = 0;
|
||||
LastUpdate = Utils.TimeStamp + 10;
|
||||
ChronomancerId = playerId;
|
||||
}
|
||||
|
||||
@@ -115,10 +110,7 @@ public class Chronomancer : RoleBase
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate >= now) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
var notify = false;
|
||||
int beforeCharge = ChargePercent;
|
||||
@@ -161,7 +153,6 @@ public class Chronomancer : RoleBase
|
||||
|
||||
public override void OnReportDeadBody()
|
||||
{
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
ChargePercent = 0;
|
||||
IsRampaging = false;
|
||||
SendRPC();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using EHR.Modules;
|
||||
|
||||
namespace EHR.Roles;
|
||||
|
||||
@@ -43,7 +44,6 @@ internal static class GeneratorStatic
|
||||
private static Dictionary<Action, int> ActionCosts = [];
|
||||
|
||||
private int Charges;
|
||||
private long LastUpdate;
|
||||
public override bool IsEnable => On;
|
||||
|
||||
public override void SetupCustomOption()
|
||||
@@ -77,7 +77,6 @@ internal static class GeneratorStatic
|
||||
On = true;
|
||||
Charges = StartingCharges.GetInt();
|
||||
playerId.SetAbilityUseLimit(Charges);
|
||||
LastUpdate = Utils.TimeStamp + 8;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
@@ -97,10 +96,7 @@ internal static class GeneratorStatic
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask || !pc.IsAlive()) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (now <= LastUpdate) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
int beforeCharges = Charges;
|
||||
bool shifted = pc.IsShifted();
|
||||
|
||||
@@ -23,7 +23,6 @@ public class RoomRusher : RoleBase
|
||||
private static OptionItem RoomsToWin;
|
||||
|
||||
private int CompletedNum;
|
||||
private long LastUpdate;
|
||||
private SystemTypes RoomGoal;
|
||||
|
||||
private byte RoomRusherId;
|
||||
@@ -57,7 +56,6 @@ public class RoomRusher : RoleBase
|
||||
RoomRusherId = playerId;
|
||||
VentsLeft = MaxVents.GetInt();
|
||||
CompletedNum = 0;
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
TimeLeft = 50;
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
@@ -181,9 +179,7 @@ public class RoomRusher : RoleBase
|
||||
StartNewRound();
|
||||
}
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate == now) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
TimeLeft--;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, RoomRusherId, 4, TimeLeft);
|
||||
|
||||
@@ -18,7 +18,6 @@ internal class SoulHunter : RoleBase
|
||||
private static OptionItem TimeToKillTarget;
|
||||
private static OptionItem GetSoulForSuicide;
|
||||
public (byte ID, long StartTimeStamp, bool Frozen) CurrentTarget = (byte.MaxValue, 0, false);
|
||||
private long LastUpdate;
|
||||
private float NormalSpeed;
|
||||
public PlayerControl SoulHunter_;
|
||||
|
||||
@@ -61,7 +60,6 @@ internal class SoulHunter : RoleBase
|
||||
SoulHunter_ = null;
|
||||
Souls = 0;
|
||||
CurrentTarget = (byte.MaxValue, 0, false);
|
||||
LastUpdate = 0;
|
||||
NormalSpeed = Main.NormalOptions.PlayerSpeedMod;
|
||||
}
|
||||
|
||||
@@ -71,7 +69,6 @@ internal class SoulHunter : RoleBase
|
||||
LateTask.New(() => { SoulHunter_ = GetPlayerById(playerId); }, 3f, log: false);
|
||||
Souls = 0;
|
||||
CurrentTarget = (byte.MaxValue, 0, false);
|
||||
LastUpdate = 0;
|
||||
NormalSpeed = Main.AllPlayerSpeed[playerId];
|
||||
}
|
||||
|
||||
@@ -140,7 +137,6 @@ internal class SoulHunter : RoleBase
|
||||
{
|
||||
CurrentTarget.ID = byte.MaxValue;
|
||||
CurrentTarget.StartTimeStamp = 0;
|
||||
LastUpdate = 0;
|
||||
Souls++;
|
||||
SoulHunter_.Notify(GetString("SoulHunterNotifySuccess"));
|
||||
LateTask.New(() => { SoulHunter_.SetKillCooldown(1f); }, 0.1f, log: false);
|
||||
@@ -151,7 +147,6 @@ internal class SoulHunter : RoleBase
|
||||
|
||||
CurrentTarget.ID = byte.MaxValue;
|
||||
CurrentTarget.StartTimeStamp = 0;
|
||||
LastUpdate = TimeStamp;
|
||||
SoulHunter_.Suicide();
|
||||
target.Notify(GetString("SoulHunterTargetNotifySurvived"));
|
||||
Logger.Info("Killed Incorrect Player => Suicide", "SoulHunter");
|
||||
@@ -178,7 +173,6 @@ internal class SoulHunter : RoleBase
|
||||
if (!SoulHunter_.IsModdedClient()) SoulHunter_.Notify(string.Format(GetString("SoulHunterNotifyFreeze"), target.GetRealName(), waitingTime + 1));
|
||||
|
||||
target.Notify(string.Format(GetString("SoulHunterTargetNotify"), SoulHunter_.GetRealName()), 300f);
|
||||
LastUpdate = now;
|
||||
|
||||
SendRPC();
|
||||
Logger.Info($"Waiting to being hunting (in {waitingTime}s)", "SoulHunter");
|
||||
@@ -195,11 +189,9 @@ internal class SoulHunter : RoleBase
|
||||
}
|
||||
|
||||
if (CurrentTarget.StartTimeStamp == 0) return;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
long now = TimeStamp;
|
||||
if (LastUpdate >= now) return;
|
||||
LastUpdate = now;
|
||||
|
||||
PlayerControl target = GetPlayerById(CurrentTarget.ID);
|
||||
string targetName = target.GetRealName();
|
||||
int waitingTime = WaitingTimeAfterMeeting.GetInt();
|
||||
|
||||
@@ -114,7 +114,6 @@ internal class Chemist : RoleBase
|
||||
private Dictionary<byte, long> Grenades;
|
||||
public bool IsBlinding;
|
||||
private Dictionary<Item, int> ItemCounts;
|
||||
private long LastUpdate;
|
||||
private string SelectedProcess;
|
||||
private readonly List<string> SortedAvailableProcesses = [];
|
||||
private readonly List<string> Available = [];
|
||||
@@ -214,7 +213,6 @@ internal class Chemist : RoleBase
|
||||
Instances.Add(this);
|
||||
|
||||
ChemistPC = Utils.GetPlayerById(playerId);
|
||||
LastUpdate = Utils.TimeStamp + 8;
|
||||
ItemCounts = [];
|
||||
CurrentFactory = Factory.None;
|
||||
SelectedProcess = string.Empty;
|
||||
@@ -499,9 +497,8 @@ internal class Chemist : RoleBase
|
||||
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask || !pc.IsAlive() || LastUpdate >= Utils.TimeStamp) return;
|
||||
|
||||
LastUpdate = Utils.TimeStamp;
|
||||
if (!GameStates.IsInTask || !pc.IsAlive()) return;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
if (ItemCounts[Item.Air] < 900)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@ public class Evolver : RoleBase
|
||||
private int ChooseTimer;
|
||||
private PlayerControl EvolverPC;
|
||||
|
||||
private long LastUpdate = Utils.TimeStamp;
|
||||
private int SelectedUpgradeIndex;
|
||||
|
||||
private (float KillCooldown, bool ImpostorVision, float Vision, float Speed, int KillDistance, bool CanVent, int VentUseLimit, bool CanSabotage, int SabotageUseLimit, bool Shielded) Stats;
|
||||
@@ -143,10 +142,7 @@ public class Evolver : RoleBase
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask || !pc.IsAlive() || ChooseTimer == 0 || SelectedUpgradeIndex == -1 || Upgrades.Count == 0) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate == now) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
ChooseTimer--;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, EvolverPC.PlayerId, 3, ChooseTimer);
|
||||
|
||||
@@ -27,7 +27,6 @@ public class Glitch : RoleBase
|
||||
public int KCDTimer;
|
||||
public long LastHack;
|
||||
public long LastKill;
|
||||
private long LastUpdate;
|
||||
|
||||
private readonly StringBuilder Suffix = new();
|
||||
|
||||
@@ -88,8 +87,6 @@ public class Glitch : RoleBase
|
||||
|
||||
LastKill = ts;
|
||||
LastHack = ts;
|
||||
|
||||
LastUpdate = ts;
|
||||
}
|
||||
|
||||
public override void Remove(byte playerId)
|
||||
@@ -147,7 +144,7 @@ public class Glitch : RoleBase
|
||||
|
||||
public override bool OnCheckMurder(PlayerControl killer, PlayerControl target)
|
||||
{
|
||||
if (killer == null || target == null || (KCDTimer > 0 && HackCDTimer > 0)) return false;
|
||||
if (KCDTimer > 0 && HackCDTimer > 0) return false;
|
||||
|
||||
if (killer.CheckDoubleTrigger(target, () =>
|
||||
{
|
||||
@@ -175,15 +172,13 @@ public class Glitch : RoleBase
|
||||
|
||||
public override void OnFixedUpdate(PlayerControl player)
|
||||
{
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(player.PlayerId)) return;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastUpdate == now) return;
|
||||
LastUpdate = now;
|
||||
|
||||
if (HackCDTimer is > 180 or < 0) HackCDTimer = 0;
|
||||
if (KCDTimer is > 180 or < 0) KCDTimer = 0;
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
if (!player.IsAlive())
|
||||
{
|
||||
HackCDTimer = 0;
|
||||
@@ -211,7 +206,7 @@ public class Glitch : RoleBase
|
||||
|
||||
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
|
||||
{
|
||||
if (seer == null || seer.PlayerId != GlitchId || seer.PlayerId != target.PlayerId || !seer.IsAlive() || (seer.IsModdedClient() && !hud) || meeting) return string.Empty;
|
||||
if (seer.PlayerId != GlitchId || seer.PlayerId != target.PlayerId || !seer.IsAlive() || (seer.IsModdedClient() && !hud) || meeting) return string.Empty;
|
||||
|
||||
Suffix.Clear();
|
||||
|
||||
|
||||
@@ -181,8 +181,6 @@ public class Magician : RoleBase
|
||||
|
||||
public static void UseCard(PlayerControl pc)
|
||||
{
|
||||
if (pc == null) return;
|
||||
|
||||
if (CardId == byte.MaxValue) return;
|
||||
|
||||
var sync = false;
|
||||
|
||||
@@ -113,7 +113,6 @@ public class RouleteGrandeur : RoleBase
|
||||
{
|
||||
long now = Utils.TimeStamp;
|
||||
if (now - LastRoll < 5) return;
|
||||
|
||||
LastRoll = now;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, 1, LastRoll);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public class Spider : RoleBase
|
||||
|
||||
private Dictionary<Vector2, Dictionary<byte, long>> Webs = [];
|
||||
private readonly List<Vector2> ToRemove = [];
|
||||
private long LastNotifyTS;
|
||||
private bool NameDirty;
|
||||
private byte SpiderId;
|
||||
|
||||
@@ -50,7 +49,6 @@ public class Spider : RoleBase
|
||||
{
|
||||
On = true;
|
||||
Webs = [];
|
||||
LastNotifyTS = 0;
|
||||
NameDirty = false;
|
||||
SpiderId = playerId;
|
||||
Instances.Add(this);
|
||||
@@ -182,10 +180,9 @@ public class Spider : RoleBase
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, SpiderId, 2, x);
|
||||
});
|
||||
|
||||
if (NameDirty && now != LastNotifyTS)
|
||||
if (NameDirty && PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId))
|
||||
{
|
||||
NameDirty = false;
|
||||
LastNotifyTS = now;
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using AmongUs.GameOptions;
|
||||
using EHR.Modules;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EHR.Roles;
|
||||
@@ -106,7 +107,7 @@ public class Tremor : RoleBase
|
||||
bool wasDoom = IsDoom;
|
||||
long now = Utils.TimeStamp;
|
||||
|
||||
if (!wasDoom && LastUpdate != now)
|
||||
if (!wasDoom && PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId))
|
||||
{
|
||||
Timer--;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, Timer);
|
||||
@@ -126,7 +127,17 @@ public class Tremor : RoleBase
|
||||
{
|
||||
Count++;
|
||||
|
||||
if (Count % 3 == 0) pc.RpcGuardAndKill();
|
||||
if (Count % 3 == 0)
|
||||
{
|
||||
if (pc.AmOwner) pc.MurderPlayer(pc, MurderResultFlags.FailedProtected);
|
||||
else
|
||||
{
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.MurderPlayer, SendOption.None, pc.OwnerId);
|
||||
writer.WriteNetObject(pc);
|
||||
writer.Write((int)MurderResultFlags.FailedProtected);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
}
|
||||
|
||||
if (Count < 15) return;
|
||||
|
||||
@@ -142,8 +153,7 @@ public class Tremor : RoleBase
|
||||
pc.Kill(target);
|
||||
}
|
||||
|
||||
if (LastUpdate == now) return;
|
||||
LastUpdate = now;
|
||||
if (!PerSecondUpdateScheduler.ShouldRunUpdate(pc.PlayerId)) return;
|
||||
|
||||
DoomTimer--;
|
||||
Utils.SendRPC(CustomRPC.SyncRoleData, pc.PlayerId, DoomTimer);
|
||||
|
||||
Reference in new issue
Block a user