Private Chat for Lovers & Fix stuff

This commit is contained in:
Gurge44 committed 2024-05-30 15:47:18 +02:00
1 parent a70a7454b3
commit e9effdd18b
11 files changed
+148 -90

No files matched your search

+2
View File
@@ -131,6 +131,8 @@ public enum CustomRoles
Convener,
CopyCat,
Bloodhound, // Coroner
LovingCrewmate,
LovingImpostor,
Crusader,
Demolitionist,
Deputy,
+53 -62
View File
@@ -195,6 +195,8 @@ public static class GuessManager
Main.GuesserGuessed.TryAdd(pc.PlayerId, 0);
bool forceAllowGuess = role is CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor or CustomRoles.Lovers && Lovers.GuessAbility.GetValue() == 2;
switch (pc.GetCustomRole())
{
case CustomRoles.NiceGuesser when Main.GuesserGuessed[pc.PlayerId] >= Options.GGCanGuessTime.GetInt():
@@ -233,14 +235,14 @@ public static class GuessManager
return true;
}
if (role.IsImpostor() && !Doomsayer.DCanGuessImpostors.GetBool())
if (role.IsImpostor() && !Doomsayer.DCanGuessImpostors.GetBool() && !forceAllowGuess)
{
if (!isUI) Utils.SendMessage(GetString("GuessNotAllowed"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessNotAllowed"));
return true;
}
if (target.IsCrewmate() && !Doomsayer.DCanGuessCrewmates.GetBool())
if (target.IsCrewmate() && !Doomsayer.DCanGuessCrewmates.GetBool() && !forceAllowGuess)
{
if (!isUI) Utils.SendMessage(GetString("GuessNotAllowed"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessNotAllowed"));
@@ -254,7 +256,7 @@ public static class GuessManager
return true;
}
if (role.IsAdditionRole() && !Doomsayer.DCanGuessAdt.GetBool())
if (role.IsAdditionRole() && !Doomsayer.DCanGuessAdt.GetBool() && !forceAllowGuess)
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
@@ -277,7 +279,7 @@ public static class GuessManager
if (!isUI) Utils.SendMessage(GetString("GuessVanillaCrewmate"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessVanillaCrewmate"));
return true;
case CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor when Lovers.CannotBeGuessed.GetBool():
case CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor when Lovers.GuessAbility.GetValue() == 0:
if (!isUI) Utils.SendMessage(GetString("GuessLovers"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessLovers"));
return true;
@@ -332,22 +334,8 @@ public static class GuessManager
case CustomRoles.GM:
Utils.SendMessage(GetString("GuessGM"), pc.PlayerId);
return true;
default:
switch (role)
{
case CustomRoles.SuperStar:
if (!isUI) Utils.SendMessage(GetString("GuessSuperStar"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessSuperStar"));
return true;
case CustomRoles.GM:
Utils.SendMessage(GetString("GuessGM"), pc.PlayerId);
return true;
}
break;
}
if (target.Is(CustomRoles.Onbound))
{
if (!isUI) Utils.SendMessage(GetString("GuessOnbound"), pc.PlayerId);
@@ -355,7 +343,7 @@ public static class GuessManager
return true;
}
if (target.Is(CustomRoles.Lovers) && Lovers.CannotBeGuessed.GetBool())
if (target.Is(CustomRoles.Lovers) && Lovers.GuessAbility.GetValue() == 0)
{
if (!isUI) Utils.SendMessage(GetString("GuessLovers"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessLovers"));
@@ -377,57 +365,60 @@ public static class GuessManager
}
// Check whether add-on guessing is allowed
switch (pc.GetCustomRole())
if (!forceAllowGuess)
{
// Assassin Can't Guess Addons
case CustomRoles.EvilGuesser when role.IsAdditionRole() && !Options.EGCanGuessAdt.GetBool():
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
// Nice Guesser Can't Guess Addons
case CustomRoles.NiceGuesser when role.IsAdditionRole() && !Options.GGCanGuessAdt.GetBool():
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
// Guesser (add-on) Can't Guess Addons
default:
if (role.IsAdditionRole() && pc.Is(CustomRoles.Guesser) && !Guesser.GCanGuessAdt.GetBool())
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
break;
}
// Guesser Mode Can/Can't Guess Addons
if (Options.GuesserMode.GetBool())
{
if (role.IsAdditionRole() && !Options.CanGuessAddons.GetBool())
switch (pc.GetCustomRole())
{
// Impostors Can't Guess Addons
if (Options.ImpostorsCanGuess.GetBool() && pc.Is(CustomRoleTypes.Impostor) && !(pc.GetCustomRole() == CustomRoles.EvilGuesser || pc.Is(CustomRoles.Guesser)))
{
// Assassin Can't Guess Addons
case CustomRoles.EvilGuesser when role.IsAdditionRole() && !Options.EGCanGuessAdt.GetBool():
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
// Nice Guesser Can't Guess Addons
case CustomRoles.NiceGuesser when role.IsAdditionRole() && !Options.GGCanGuessAdt.GetBool():
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
// Guesser (add-on) Can't Guess Addons
default:
if (role.IsAdditionRole() && pc.Is(CustomRoles.Guesser) && !Guesser.GCanGuessAdt.GetBool())
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
// Crewmates Can't Guess Addons
if (Options.CrewmatesCanGuess.GetBool() && pc.Is(CustomRoleTypes.Crewmate) && !(pc.GetCustomRole() == CustomRoles.NiceGuesser || pc.Is(CustomRoles.Guesser)))
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
break;
}
// Neutrals Can't Guess Addons
if ((Options.NeutralKillersCanGuess.GetBool() || Options.PassiveNeutralsCanGuess.GetBool()) && pc.Is(CustomRoleTypes.Neutral) && !(pc.GetCustomRole() is CustomRoles.Ritualist or CustomRoles.Doomsayer || pc.Is(CustomRoles.Guesser)))
// Guesser Mode Can/Can't Guess Addons
if (Options.GuesserMode.GetBool())
{
if (role.IsAdditionRole() && !Options.CanGuessAddons.GetBool())
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
// Impostors Can't Guess Addons
if (Options.ImpostorsCanGuess.GetBool() && pc.Is(CustomRoleTypes.Impostor) && !(pc.GetCustomRole() == CustomRoles.EvilGuesser || pc.Is(CustomRoles.Guesser)))
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
// Crewmates Can't Guess Addons
if (Options.CrewmatesCanGuess.GetBool() && pc.Is(CustomRoleTypes.Crewmate) && !(pc.GetCustomRole() == CustomRoles.NiceGuesser || pc.Is(CustomRoles.Guesser)))
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
// Neutrals Can't Guess Addons
if ((Options.NeutralKillersCanGuess.GetBool() || Options.PassiveNeutralsCanGuess.GetBool()) && pc.Is(CustomRoleTypes.Neutral) && !(pc.GetCustomRole() is CustomRoles.Ritualist or CustomRoles.Doomsayer || pc.Is(CustomRoles.Guesser)))
{
if (!isUI) Utils.SendMessage(GetString("GuessAdtRole"), pc.PlayerId);
else pc.ShowPopUp(GetString("GuessAdtRole"));
return true;
}
}
}
}
+51 -12
View File
@@ -5,23 +5,62 @@ namespace EHR;
public interface IRandom
{
// A list of classes that implement IRandom
public static readonly Dictionary<int, Type> RandomTypes = new()
{
{ 0, typeof(NetRandomWrapper) }, // Default
{ 1, typeof(NetRandomWrapper) },
{ 2, typeof(HashRandomWrapper) },
{ 3, typeof(Xorshift) },
{ 4, typeof(MersenneTwister) }
};
public static IRandom Instance { get; private set; }
/// <summary>Generates a random number greater than or equal to 0 and less than maxValue.</summary>
public int Next(int maxValue);
/// <summary>Generates a random number greater than or equal to minValue and less than maxValue.</summary>
public int Next(int minValue, int maxValue);
// == static ==
// IRandomを実装するクラスのリスト
public static Dictionary<int, Type> randomTypes = new()
{
{ 0, typeof(NetRandomWrapper) }, //Default
{ 1, typeof(NetRandomWrapper) },
{ 2, typeof(HashRandomWrapper) },
{ 3, typeof(Xorshift) },
{ 4, typeof(MersenneTwister) },
};
public static IRandom Instance { get; private set; }
/// <summary>
/// Generates a sequence of random numbers.
/// </summary>
/// <param name="count">The number of random numbers to generate.</param>
/// <param name="minValue">The inclusive lower bound of the random numbers to generate.</param>
/// <param name="maxValue">The exclusive upper bound of the random numbers to generate.</param>
/// <returns>A sequence of random numbers.</returns>
public static IEnumerable<int> Sequence(int count, int minValue, int maxValue)
{
for (int i = 0; i < count; i++)
{
yield return Instance.Next(minValue, maxValue);
}
}
/// <summary>
/// Generates a sequence of unique random numbers.
/// </summary>
/// <param name="count">The number of random numbers to generate.</param>
/// <param name="minValue">The inclusive lower bound of the random numbers to generate.</param>
/// <param name="maxValue">The exclusive upper bound of the random numbers to generate.</param>
/// <returns>A sequence of unique random numbers.</returns>
public static IEnumerable<int> SequenceUnique(int count, int minValue, int maxValue)
{
var set = new HashSet<int>();
for (int i = 0; i < count; i++)
{
// If all possible values are used, the loop will be infinite. Break the loop if the set is full.
if (set.Count == maxValue - minValue) break;
int value;
do value = Instance.Next(minValue, maxValue);
while (!set.Add(value));
yield return value;
}
}
public static void SetInstance(IRandom instance)
{
if (instance != null)
@@ -30,9 +69,9 @@ public interface IRandom
public static void SetInstanceById(int id)
{
if (randomTypes.TryGetValue(id, out var type))
if (RandomTypes.TryGetValue(id, out var type))
{
// 現在のインスタンスがnull または 現在のインスタンスの型が指定typeと一致しない
// The current instance is null or the type of the current instance does not match the specified type.
if (Instance == null || Instance.GetType() != type)
{
Instance = Activator.CreateInstance(type) as IRandom ?? Instance;
+6
View File
@@ -2470,6 +2470,12 @@ public static class Utils
public static void AfterMeetingTasks()
{
if (Lovers.PrivateChat.GetBool() && !GameStates.IsEnded)
{
SetChatVisible();
return;
}
Main.ProcessShapeshifts = true;
foreach (var pc in Main.AllPlayerControls)
+3 -2
View File
@@ -224,12 +224,13 @@ class HudManagerPatch
},
_ => string.Empty,
};
if (GetCD_HUDText() != string.Empty) LowerInfoText.text = $"{GetCD_HUDText()}\n{LowerInfoText.text}";
string GetCD_HUDText() => !Options.UsePets.GetBool() || !Main.AbilityCD.TryGetValue(player.PlayerId, out var CD)
string CD_HUDText = !Options.UsePets.GetBool() || !Main.AbilityCD.TryGetValue(player.PlayerId, out var CD)
? string.Empty
: string.Format(GetString("CDPT"), CD.TOTALCD - (Utils.TimeStamp - CD.START_TIMESTAMP) + 1);
if (CD_HUDText != string.Empty) LowerInfoText.text = $"{CD_HUDText}\n{LowerInfoText.text}";
LowerInfoText.enabled = LowerInfoText.text != string.Empty;
if ((!AmongUsClient.Instance.IsGameStarted && AmongUsClient.Instance.NetworkMode != NetworkModes.FreePlay) || GameStates.IsMeeting)
+6
View File
@@ -707,6 +707,12 @@ internal class SelectRolesPatch
private static void AssignLoversRoles(int RawCount = -1)
{
if (Lovers.LegacyLovers.GetBool())
{
Main.LoversPlayers = Main.AllPlayerControls.Where(x => x.GetCustomRole() is CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor).Take(2).ToList();
return;
}
var allPlayers = Main.AllPlayerControls.Where(pc => !pc.Is(CustomRoles.GM) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && !pc.Is(CustomRoles.Dictator) && !pc.Is(CustomRoles.God) && !pc.Is(CustomRoles.FFF) && !pc.Is(CustomRoles.Bomber) && !pc.Is(CustomRoles.Nuker) && !pc.Is(CustomRoles.Provocateur) && (!pc.IsCrewmate() || Options.CrewCanBeInLove.GetBool()) && (!pc.GetCustomRole().IsNeutral() || Options.NeutralCanBeInLove.GetBool()) && (!pc.GetCustomRole().IsImpostor() || Options.ImpCanBeInLove.GetBool())).ToList();
const CustomRoles role = CustomRoles.Lovers;
var count = Math.Clamp(RawCount, 0, allPlayers.Count);
+3 -2
View File
@@ -1353,8 +1353,9 @@
"LoverKnowRoles": "<color=#ff9ace>Lovers</color> know the roles of each other",
"LegacyLovers": "Legacy Lovers",
"LovingImpostorSpawnChance": "<color=#ff9ace>Loving</color> <#ff1919>Impostor</color> Spawn Chance",
"PrivateChat": "Enable Private Chat for Lovers",
"CannotBeGuessed": "<color=#ff9ace>Lovers</color> Cannot Be Guessed",
"PrivateChat": "Enable Private Chat for Lovers <#ffff00>(VERY EXPERIMENTAL!!!!)</color>",
"GuessAbility": "Guessers Can Guess Lovers",
"Untouched": "Untouched",
"GuessLovers": "Sorry, <color=#ff9ace>Lovers</color> cannot be guessed.",
"GuessVanillaCrewmate": "Did you seriously just try to guess someone as vanilla crewmate?! Shame on you!",
"TrapperBlockMoveTime": "Freeze time",
+13 -5
View File
@@ -4,12 +4,19 @@ namespace EHR.Roles.AddOns.Common
{
internal class Lovers : IAddon
{
public AddonTypes Type => AddonTypes.Mixed;
public static OptionItem LegacyLovers;
public static OptionItem LovingImpostorSpawnChance;
public static OptionItem PrivateChat;
public static OptionItem CannotBeGuessed;
public static OptionItem GuessAbility;
private static readonly string[] GuessModes =
[
"RoleOff", // 0
"Untouched", // 1
"RoleOn" // 2
];
public AddonTypes Type => AddonTypes.Mixed;
public void SetupCustomOption()
{
@@ -54,13 +61,14 @@ namespace EHR.Roles.AddOns.Common
LovingImpostorSpawnChance = FloatOptionItem.Create(id + 9, "LovingImpostorSpawnChance", new(0, 100, 5), 25, TabGroup.Addons)
.SetParent(LegacyLovers)
.SetValueFormat(OptionFormat.Percent)
.SetGameMode(customGameMode);
PrivateChat = BooleanOptionItem.Create(id + 10, "PrivateChat", false, TabGroup.Addons)
.SetParent(spawnOption)
.SetGameMode(customGameMode);
CannotBeGuessed = BooleanOptionItem.Create(id + 11, "CannotBeGuessed", false, TabGroup.Addons)
GuessAbility = StringOptionItem.Create(id + 11, "GuessAbility", GuessModes, 1, TabGroup.Addons)
.SetParent(spawnOption)
.SetGameMode(customGameMode);
@@ -76,4 +84,4 @@ namespace EHR.Roles.AddOns.Common
CustomAdtRoleSpawnRate.Add(role, rateOption);
}
}
}
}
+8 -4
View File
@@ -28,10 +28,14 @@ namespace EHR.Roles.Crewmate
public static void SetupCustomOption()
{
SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Bloodhound);
ArrowsPointingToDeadBody = BooleanOptionItem.Create(Id + 10, "BloodhoundArrowsPointingToDeadBody", false, TabGroup.CrewmateRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
LeaveDeadBodyUnreportable = BooleanOptionItem.Create(Id + 11, "BloodhoundLeaveDeadBodyUnreportable", false, TabGroup.CrewmateRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
NotifyKiller = BooleanOptionItem.Create(Id + 14, "BloodhoundNotifyKiller", false, TabGroup.CrewmateRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
UseLimitOpt = IntegerOptionItem.Create(Id + 12, "AbilityUseLimit", new(0, 20, 1), 1, TabGroup.CrewmateRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound])
ArrowsPointingToDeadBody = BooleanOptionItem.Create(Id + 10, "BloodhoundArrowsPointingToDeadBody", false, TabGroup.CrewmateRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
LeaveDeadBodyUnreportable = BooleanOptionItem.Create(Id + 11, "BloodhoundLeaveDeadBodyUnreportable", false, TabGroup.CrewmateRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
NotifyKiller = BooleanOptionItem.Create(Id + 14, "BloodhoundNotifyKiller", false, TabGroup.CrewmateRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound]);
UseLimitOpt = IntegerOptionItem.Create(Id + 12, "AbilityUseLimit", new(0, 20, 1), 1, TabGroup.CrewmateRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound])
.SetValueFormat(OptionFormat.Times);
BloodhoundAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(Id + 13, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.05f), 0.2f, TabGroup.CrewmateRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Bloodhound])
+2 -2
View File
@@ -252,8 +252,8 @@ namespace EHR.Roles.Neutral
return new(title, allAnswersList.ToArray(), correctIndex);
IEnumerable<string> GetTwoRandomNames(string except) => Main.AllPlayerControls.Select(x => x?.GetRealName()).Remove(except).Shuffle().TakeLast(2);
IEnumerable<string> GetTwoRandomNumbers(params int[] nums) => Enumerable.Range(nums[1], nums[2]).Remove(nums[0]).Shuffle().Take(2).Select(x => x.ToString());
IEnumerable<string> GetTwoRandomNames(string except) => Main.AllPlayerControls.Select(x => x?.GetRealName()).Without(except).Shuffle().TakeLast(2);
IEnumerable<string> GetTwoRandomNumbers(params int[] nums) => IRandom.SequenceUnique(3, nums[1], nums[2] + 1).Without(nums[0]).Take(2).Select(x => x.ToString());
}
public override void OnReportDeadBody()
+1 -1
View File
@@ -101,7 +101,7 @@ public class Main : BasePlugin
public static int FirstDied = int.MaxValue;
public static int ShieldPlayer = int.MaxValue;
public static readonly List<PlayerControl> LoversPlayers = [];
public static List<PlayerControl> LoversPlayers = [];
public static bool IsLoversDead = true;
public static List<byte> CyberStarDead = [];
public static List<byte> BaitAlive = [];