fix beacon, optimize mastermind, draft role % respect setting

This commit is contained in:
Gurge44 committed 2026-01-20 09:57:16 +01:00
1 parent dbe0f3837f
commit e72920e2a6
6 files changed
+24 -16

No files matched your search

+1
View File
@@ -368,6 +368,7 @@ namespace EHR
System.Collections.IEnumerator WaitForMeetingEnd()
{
yield return new WaitForSecondsRealtime(5f);
while (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks) yield return null;
yield return new WaitForSecondsRealtime(1f);
while (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks) yield return null;
+4
View File
@@ -743,6 +743,7 @@ public static class Options
public static OptionItem EnableAutoMessage;
public static OptionItem AutoMessageSendInterval;
public static OptionItem DraftMaxRolesPerPlayer;
public static OptionItem DraftAffectedByRoleSpawnChances;
public static OptionItem LargerRoleTextSize;
public static OptionItem DynamicTaskCountColor;
public static OptionItem ShowTaskCountWhenAlive;
@@ -3013,6 +3014,9 @@ public static class Options
DraftMaxRolesPerPlayer = new IntegerOptionItem(19431, "DraftMaxRolesPerPlayer", new(1, 30, 1), 5, TabGroup.GameSettings)
.SetGameMode(CustomGameMode.Standard)
.SetColor(new Color32(193, 255, 209, byte.MaxValue));
DraftAffectedByRoleSpawnChances = new BooleanOptionItem(19435, "DraftAffectedByRoleSpawnChances", false, TabGroup.GameSettings)
.SetColor(new Color32(193, 255, 209, byte.MaxValue));
LargerRoleTextSize = new BooleanOptionItem(24451, "LargerRoleTextSize", false, TabGroup.GameSettings)
.SetColor(new Color32(193, 255, 209, byte.MaxValue));
+2 -1
View File
@@ -1425,7 +1425,8 @@ internal static class ChatCommands
DraftResult = [];
byte[] allPlayerIds = Main.AllPlayerControls.Select(x => x.PlayerId).ToArray();
List<CustomRoles> allRoles = Enum.GetValues<CustomRoles>().Where(x => x < CustomRoles.NotAssigned && x.IsEnable() && !x.IsForOtherGameMode() && !CustomHnS.AllHnSRoles.Contains(x) && !x.IsVanilla() && x is not CustomRoles.GM).Shuffle();
bool rollSpawnChance = Options.DraftAffectedByRoleSpawnChances.GetBool();
List<CustomRoles> allRoles = Enum.GetValues<CustomRoles>().Where(x => x < CustomRoles.NotAssigned && x.IsEnable() && !x.IsForOtherGameMode() && !CustomHnS.AllHnSRoles.Contains(x) && !x.IsVanilla() && x is not CustomRoles.GM && (!rollSpawnChance || IRandom.Instance.Next(100) < x.GetMode())).Shuffle();
if (allRoles.Count < allPlayerIds.Length)
{
+1
View File
@@ -3024,6 +3024,7 @@
"DraftTitle": "<#00a5ff>➡</color> <#00ffa5>Drafting</color> <#00a5ff>⬅</color>",
"DraftChosen": "You have chosen the <b>{0}</b> role for the next game.\\n<size=70%>You can still change your choice by typing /draft [index] again.</size>",
"DraftMaxRolesPerPlayer": "Max Roles For Each Player To Choose From When Drafting",
"DraftAffectedByRoleSpawnChances": "Take Role Spawn Chances Into Account When Picking Draft Choices",
"EveryoneDrafted": "<#00ffa5>✓</color> <#00ff00>Everyone has drafted their role!</color>",
"DeathCommand": "<#ffffff>You were killed by </color>{0}<#ffffff>\\nTheir role is </color>{1}",
"DeathCommandFail": "<#ff0000>The game could not determine your real killer.</color>\\nYour death reason is <#00ffa5>{0}</color>.",
+6 -11
View File
@@ -57,35 +57,30 @@ internal class Beacon : RoleBase
public override void OnCheckPlayerPosition(PlayerControl pc)
{
if (!GameStates.IsInTask || pc == null) return;
long now = Utils.TimeStamp;
if (LastChange.TryGetValue(pc.PlayerId, out long ts) && ts == now) return;
Vector2 pos = pc.Pos();
float radius = Radius.GetFloat();
bool beaconNearby = Beacons.Any(x => Vector2.Distance(x.Pos(), pos) <= radius);
bool affectedPlayer = AffectedPlayers.Contains(pc.PlayerId);
bool lightsOff = Utils.IsActive(SystemTypes.Electrical);
switch (affectedPlayer)
switch (affectedPlayer: AffectedPlayers.Contains(pc.PlayerId), beaconNearby: Utils.IsActive(SystemTypes.Electrical) && Beacons.Any(x => Vector2.Distance(x.Pos(), pos) <= radius))
{
case true when !beaconNearby:
case (affectedPlayer: true, beaconNearby: false):
{
AffectedPlayers.Remove(pc.PlayerId);
if (lightsOff) pc.MarkDirtySettings();
pc.MarkDirtySettings();
LastChange[pc.PlayerId] = now;
break;
}
case false when beaconNearby:
case (affectedPlayer: false, beaconNearby: true):
{
AffectedPlayers.Add(pc.PlayerId);
if (lightsOff) pc.MarkDirtySettings();
pc.MarkDirtySettings();
LastChange[pc.PlayerId] = now;
if (pc.AmOwner && lightsOff)
if (pc.AmOwner)
Achievements.Type.ALightInTheShadows.CompleteAfterGameEnd();
break;
@@ -85,10 +85,16 @@ public class Mastermind : RoleBase
});
}
private long LastUpdate;
public override void OnFixedUpdate(PlayerControl _)
{
if (!IsEnable || GameStates.IsMeeting || (ManipulatedPlayers.Count == 0 && ManipulateDelays.Count == 0)) return;
long now = TimeStamp;
if (now == LastUpdate) return;
LastUpdate = now;
foreach (KeyValuePair<byte, long> x in ManipulateDelays)
{
PlayerControl pc = GetPlayerById(x.Key);
@@ -99,10 +105,10 @@ public class Mastermind : RoleBase
continue;
}
if (x.Value + Delay.GetInt() < TimeStamp)
if (x.Value + Delay.GetInt() < now)
{
ManipulateDelays.Remove(x.Key);
ManipulatedPlayers.TryAdd(x.Key, TimeStamp);
ManipulatedPlayers.TryAdd(x.Key, now);
if (pc.HasKillButton()) TempKCDs.TryAdd(pc.PlayerId, Main.KillTimers[pc.PlayerId]);
else pc.RpcChangeRoleBasis(CustomRoles.SerialKiller);
@@ -123,7 +129,7 @@ public class Mastermind : RoleBase
continue;
}
if (x.Value + TimeLimit.GetInt() < TimeStamp)
if (x.Value + TimeLimit.GetInt() < now)
{
ManipulatedPlayers.Remove(x.Key);
if (!TempKCDs.Remove(x.Key)) player.RpcChangeRoleBasis(player.GetCustomRole());
@@ -134,7 +140,7 @@ public class Mastermind : RoleBase
Achievements.Type.OutOfTime.Complete();
}
long time = TimeLimit.GetInt() - (TimeStamp - x.Value);
long time = TimeLimit.GetInt() - (now - x.Value);
player.Notify(string.Format(GetString("ManipulateNotify"), time), 3f, true);
}